Runs benchmark on each optimization level.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 9 Jan 2017 10:52:12 +0000 (11:52 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 9 Jan 2017 10:52:38 +0000 (11:52 +0100)
test/bench.js

index a7f04f3..227af6a 100644 (file)
@@ -1,14 +1,22 @@
 var CleanCSS = require('../index');
 
 var input = '@import url(test/fixtures/bench/complex.css);';
-var total = 0;
+var total;
+var level;
+var i;
+var start;
+var itTook;
 
-for (var i = 1; i <= 10; i++) {
-  var start = process.hrtime();
-  new CleanCSS().minify(input);
+for (level = 0; level < 3; level ++) {
+  total = 0;
 
-  var itTook = process.hrtime(start);
-  total += 1000 * itTook[0] + itTook[1] / 1000000;
-}
+  for (i = 1; i <= 10; i++) {
+    start = process.hrtime();
+    new CleanCSS({ level: level }).minify(input);
+
+    itTook = process.hrtime(start);
+    total += 1000 * itTook[0] + itTook[1] / 1000000;
+  }
 
-console.log('Complete minification averaged over 10 runs: %d ms', total / 10);
+  console.log('Average over 10 runs on level %d: %d ms', level, total / 10);
+}