dart-sass/perf.md
Natalie Weizenbaum eec6ccc9d9 Update benchmarks
2019-07-16 19:50:25 -07:00

5.8 KiB

These benchmarks are informal and only intended to give us a general sense of the benefit Dart Sass could provide relative to other implementations.

This was tested against:

  • libsass ac338dfd and sassc a873899 compiled with g++ (Debian 7.3.0-18) 7.3.0.
  • Dart Sass 143e02a on Dart 2.4.0 and Node v12.0.0.

on Debian x64 with Intel Xeon E5-1650 v3 @ 3.50GHz. The Dart Sass application snapshot was trained on the tool/app-snapshot-input.scss file.

Measurements

I ran five instances of each configuration and recorded the fastest time.

Small Plain CSS

Running on a file containing 4 instances of .foo {a: b}:

  • sassc: 0.005s
  • Dart Sass from a script snapshot: 0.219s
  • Dart Sass native executable: 0.019s
  • Dart Sass on Node.js: 0.195s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 3.8x slower than libsass
  • 10.3x faster than Dart Sass on Node

Large Plain CSS

Running on a file containing 2^17 instances of .foo {a: b}:

  • sassc: 1.735s
  • Dart Sass from a script snapshot: 1.573s
  • Dart Sass native executable: 1.460s
  • Dart Sass on Node.js: 2.729s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.2x faster than libsass
  • 1.9x faster than Dart Sass on Node

Preceding Sparse @extend

Running on a file containing .x {@extend .y}, 2^17 instances of .foo {a: b}, and then .y {a: b}:

  • sassc: 1.739s
  • Dart Sass from a script snapshot: 1.634s
  • Dart Sass native executable: 1.574s
  • Dart Sass on Node.js: 2.877s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.1x faster than libsass
  • 1.8x faster than Dart Sass on Node

Following Sparse @extend

Running on a file containing .y {a: b}, 2^17 instances of .foo {a: b}, and then .x {@extend .y}:

  • sassc: 1.726s
  • Dart Sass from a script snapshot: 1.536s
  • Dart Sass native executable: 1.512s
  • Dart Sass on Node.js: 2.768s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.1x faster than libsass
  • 1.8x faster than Dart Sass on Node

Preceding Dense @extend

Running on a file containing .bar {@extend .foo} followed by 2^17 instances of .foo {a: b}:

  • sassc: 2.356s
  • Dart Sass from a script snapshot: 2.556s
  • Dart Sass native executable: 2.628s
  • Dart Sass on Node.js: 5.737s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.1x slower than libsass
  • 2.2x faster than Dart Sass on Node

Following Dense @extend

Running on a file containing 2^17 instances of .foo {a: b} followed by .bar {@extend .foo}:

  • sassc: 2.377s
  • Dart Sass from a script snapshot: 2.420s
  • Dart Sass native executable: 2.440s
  • Dart Sass on Node.js: 5.841s

Based on these numbers, Dart Sass from a native executable is approximately:

  • identical to libsass
  • 2.4x faster than Dart Sass on Node

Bootstrap

Running on a file containing 16 instances of importing the Bootstrap framework:

  • sassc: 0.820s
  • Dart Sass from a script snapshot: 1.558s
  • Dart Sass native executable: 0.927s
  • Dart Sass on Node.js: 3.129s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.1x slower than libsass
  • 3.4x faster than Dart Sass on Node

a11ycolor

Running on a file containing test cases for a computation-intensive color-processing library:

  • sassc: 0.264s
  • Dart Sass from a script snapshot: 0.699s
  • Dart Sass native executable: 0.375s
  • Dart Sass on Node.js: 0.792s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.4x slower than libsass
  • 2.1x faster than Dart Sass on Node

Susy

Running on a file containing test cases for the computation-intensive Susy grid framework:

  • sassc: 0.233s
  • Dart Sass from a script snapshot: 0.694s
  • Dart Sass native executable: 0.184s
  • Dart Sass on Node.js: 0.909s

Based on these numbers, Dart Sass from a native executable is approximately:

  • 1.3x faster than libsass
  • 4.9x faster than Dart Sass on Node

Prior Measurements

Conclusions

This is the first measurement with Dart Sass running as ahead-of-time-compiled native code, and the results are encouraging. It's well below the 100ms threshold for tiny files, and it's on par with SassC for most test cases. SassC still leads for tests with many extends, although only slightly, and for one of our real-world test cases (although Dart Sass leads in others). The two implementations can be fairly described as having about the same performance overall.

Dart Sass on Node is still substantially slower than on the Dart VM, and that relative slowdown becomes more pronounced as the raw Dart code becomes faster. Solutions for this such as [the embedded protocol][] or [WebAssembly support][] are becoming more and more important.