MCPcopy Create free account
hub / github.com/babel/minify / runFile

Method runFile

scripts/benchmark.js:47–80  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

45 return this.results;
46 }
47 runFile(filename) {
48 if (DEBUG) console.error(`Benchmark - ${filename}`);
49
50 const code = this.getFile(filename);
51 const gzipped = zlib.gzipSync(code);
52
53 const result = {
54 input: code,
55 gzipped,
56 filename,
57 items: [
58 this.test(this["babel-minify"], code),
59 this.test(this["terser"], code),
60 this.test(this["uglify"], code),
61 this.test(this["closure-compiler"], filename, false),
62 this.test(this["closure-compiler-js"], code)
63 ]
64 };
65
66 const min = Math.min(...result.items.map(item => item.gzipped.length));
67 const max = Math.max(...result.items.map(item => item.gzipped.length));
68
69 for (const item of result.items) {
70 if (item.gzipped.length === min) {
71 item.isMin = true;
72 }
73 if (item.gzipped.length === max) {
74 item.isMax = true;
75 }
76 }
77
78 this.results.push(result);
79 return result;
80 }
81 test(fn, arg, warmup = false) {
82 // eslint-disable-line
83 if (DEBUG) console.error(`Running ${fn.name}`);

Callers 2

runAndPrintMethod · 0.95
runMethod · 0.95

Calls 3

getFileMethod · 0.95
testMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected