From 47486aab3749ed0a3ccfc98bfb26c2e61aa123df Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Mon, 9 Jan 2017 11:52:12 +0100 Subject: [PATCH] Runs benchmark on each optimization level. --- test/bench.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/bench.js b/test/bench.js index a7f04f38..227af6ad 100644 --- a/test/bench.js +++ b/test/bench.js @@ -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); +} -- 2.34.1