Skip to content

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented Feb 24, 2023

This PR ports sass-contrib/sass-embedded-host-ruby@e14de4a...f085250, which improves the launch speed of compiler process.

In order to better measure the cost of compiler startup, all the compilations are done sequentially. Test is done on M1 Macbook Pro. Results may vary depends on the platform, but all platforms should see faster launch.

Before:

500 compileStringAsync took 11480.290958046913 milliseconds.
500 compileString took 21916.757833003998 milliseconds.

After:

500 compileStringAsync took 8629.174999952316 milliseconds.
500 compileString took 19083.104707956314 milliseconds.

Benchmark script:

const sass = require('sass-embedded');

async function benchmark (n) {
  const t0 = performance.now();

  for (let i = 0; i < n; i++) {
    await sass.compileStringAsync('a{b:c}');
  }

  const t1 = performance.now();

  console.log(`${n} compileStringAsync took ${t1 - t0} milliseconds.`);

  const t2 = performance.now();

  for (let i = 0; i < n; i++) {
    sass.compileString('a{b:c}');
  }

  const t3 = performance.now();

  console.log(`${n} compileString took ${t3 - t2} milliseconds.`);
}

benchmark(process.argv[2] || 500);

nex3 added a commit to sass/dart-sass that referenced this pull request Feb 28, 2023
@nex3 nex3 merged commit 3088620 into sass:main Feb 28, 2023
nex3 added a commit to sass/dart-sass that referenced this pull request Feb 28, 2023
@ntkme ntkme deleted the fast-launch branch February 28, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants