-
-
Save mgreter/355197a55dc6c8cac7d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sass = require('node-sass'); | |
var elapsed_time = function(time) { | |
var elapsed = time[1] / 1000000; | |
console.log("libsass in ", time[0] + " s, " + elapsed.toFixed(3) + " ms"); | |
} | |
var scss = '$main-font-size: 16px;'; | |
for (var i = 0; i < 150; i++) { | |
scss += 'body { font-size: $main-font-size; }'; | |
scss += 'h1 { font-size: $main-font-size * 2; }'; | |
scss += 'pre { height: 100px - 2px; }'; | |
} | |
var start = process.hrtime(); | |
var result = sass.renderSync({ | |
data: scss | |
}); | |
var stop = process.hrtime(start); | |
// console.log(result.css); | |
elapsed_time(stop); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var postcss = require("postcss"); | |
var calc = require("postcss-calc"); | |
var vars = require("postcss-custom-properties"); | |
var elapsed_time = function(time) { | |
var elapsed = time[1] / 1000000; | |
console.log("postcss in ", time[0] + " s, " + elapsed.toFixed(3) + " ms"); | |
} | |
var css = ':root { --main-font-size: 16px; }'; | |
for (var i = 0; i < 150; i++) { | |
css += 'body { font-size: var(--main-font-size); }'; | |
css += 'h1 { font-size: calc(var(--main-font-size) * 2); }'; | |
css += 'pre { height: calc(100px - 2px); }'; | |
} | |
var start = process.hrtime(); | |
var output = postcss() | |
.use(vars()) | |
.use(calc()) | |
.process(css) | |
.css | |
var stop = process.hrtime(start); | |
// console.log(output); | |
elapsed_time(stop); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libsass in 0 s, 135.280 ms | |
postcss in 0 s, 283.103 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat /proc/cpuinfo | |
vendor_id : GenuineIntel | |
cpu family : 6 | |
model : 28 | |
model name : Intel(R) Atom(TM) CPU 330 @ 1.60GHz | |
stepping : 2 | |
microcode : 0x219 | |
cpu MHz : 1596.074 | |
cache size : 512 KB | |
# node -v | |
v0.10.30 | |
# node-sass -v | |
node-sass 3.0.0-beta.7 (Wrapper) [JavaScript] | |
libsass 3.2.0-beta.6 (Sass Compiler) [C/C++] | |
# not sure how to fetch postcss version | |
# according to npm install it's 4.1.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I updated benchmark with more real examples: nesting, variables, mixins, math: https://github.com/postcss/postcss/blob/master/benchmark/general.js
But I got different result:
But I didn’t still use Bootstrap before mixins/variables. It contains comments, at-rules, whitespaces. It is a good test for real world parsing, so we can’t miss it.
@mgreter Can you check my updated benchmark. Maybe I loose something.