tiret
v2.1.2
Published
benchmark runner.
Downloads
25
Readme
tiret
Note: benchmark runner.
Usage
Globally using
$ npm i tiret -g
$ tiret ./test/*.test.js
API
import { runFiles } from 'tiret';
runFiles('./test/*.test.mjs', {
async: true,
done(msg) {
console.info(msg);
}
});
import { run } from 'tiret';
function min(a, b) {
return a < b ? a : b;
}
const array = Array.from({ length: 1000 });
for (let i = 0; i < array.length; i++) {
array[i] = Math.round(Math.random() * 10);
}
run({
'【Math.min】'() {
for (let i = 0, len = array.length - 1; i < len; i += 2) {
Math.min(array[i], array[i + 1]);
}
},
'【min】'() {
for (let i = 0, len = array.length - 1; i < len; i += 2) {
min(array[i], array[i + 1]);
}
}
});
*.test.mjs
example
function max(a, b) {
return a > b ? a : b;
}
const array = Array.from({ length: 1000 });
for (let i = 0; i < array.length; i++) {
array[i] = Math.round(Math.random() * 10);
}
// 测试 max
export default {
'【Math.max】'() {
for (let i = 0, len = array.length - 1; i < len; i += 2) {
Math.max(array[i], array[i + 1]);
}
},
'【max】'() {
for (let i = 0, len = array.length - 1; i < len; i += 2) {
max(array[i], array[i + 1]);
}
}
};