Skip to content

Commit 906883b

Browse files
committed
Add benchmarking
1 parent ebf1aa5 commit 906883b

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
imgs/

.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test/
2+
docs/
3+
extest/
4+
imgs/

extest/bench.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const s = require('../index');
2+
const runs = 20;
3+
const input = process.argv[2];
4+
if (!input) {
5+
console.error('Input image path required');
6+
process.exit(1);
7+
}
8+
9+
runTest(() => s.toAnsii(process.argv[2])).then(console.log);
10+
11+
async function runTest(test) {
12+
const results = [];
13+
for (let tI = 0; tI < 20; tI++){
14+
const start = Date.now();
15+
await test();
16+
results.push(Date.now() - start);
17+
}
18+
19+
return {
20+
results: results.slice(),
21+
avg: results.reduce((tot, r) => tot + r, 0) / results.length,
22+
max: results.sort().reverse()[0],
23+
min: results.sort()[0],
24+
tot: results.reduce((tot, r) => tot + r, 0)
25+
};
26+
}

package-lock.json

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"terminal"
2020
],
2121
"author": "patmooney",
22-
"license": "SEE LICENSE IN LICENSE",
22+
"license": "MIT",
2323
"bugs": {
2424
"url": "https://github.com/patmooney/node-terminal-art/issues"
2525
},

0 commit comments

Comments
 (0)