makefile test

This commit is contained in:
Brooke Vibber 2023-09-04 10:19:17 -07:00
parent f7a6a4ab02
commit 7878913dd9
2 changed files with 26 additions and 19 deletions

5
Makefile Normal file
View file

@ -0,0 +1,5 @@
test :
node speci.js x-first
node speci.js y-first
node speci.js mixed
node speci.js randomized

View file

@ -1,4 +1,4 @@
function doit() {
function doit(mode) {
function make_x_first(x,y) {
return {x, y};
@ -34,7 +34,7 @@ function doit() {
const million = 1000 * 1000;
const n = 1 * million;
const runs = 100 * n;
const runs = 1000 * n;
function bulk(filler) {
let a = [];
@ -44,10 +44,21 @@ function doit() {
return a;
}
const x_first = bulk(make_x_first);
const y_first = bulk(make_y_first);
const mixed = bulk(make_mixed);
const randomized = bulk(make_randomized);
let funcMap = {
'x-first': make_x_first,
'y-first': make_y_first,
'mixed': make_mixed,
'randomized': make_randomized,
};
let func = funcMap[mode];
if (!func) {
console.log(`Pass as parameter one of:`);
for (let key of Object.keys(funcMap)) {
console.log(` ${key}`);
}
process.exit(1);
}
const data = bulk(func);
function time(func) {
const start = Date.now();
@ -77,18 +88,9 @@ function doit() {
}
}
console.log(`** x_first`);
demo(x_first);
console.log(`** y_first`);
demo(y_first);
console.log(`** mixed`);
demo(mixed);
console.log(`** randomized`);
demo(randomized);
console.log(`** ${mode}`);
demo(data);
}
doit();
let mode = String(process.argv[2]);
doit(mode);