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) { function make_x_first(x,y) {
return {x, y}; return {x, y};
@ -34,7 +34,7 @@ function doit() {
const million = 1000 * 1000; const million = 1000 * 1000;
const n = 1 * million; const n = 1 * million;
const runs = 100 * n; const runs = 1000 * n;
function bulk(filler) { function bulk(filler) {
let a = []; let a = [];
@ -44,10 +44,21 @@ function doit() {
return a; return a;
} }
const x_first = bulk(make_x_first); let funcMap = {
const y_first = bulk(make_y_first); 'x-first': make_x_first,
const mixed = bulk(make_mixed); 'y-first': make_y_first,
const randomized = bulk(make_randomized); '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) { function time(func) {
const start = Date.now(); const start = Date.now();
@ -77,18 +88,9 @@ function doit() {
} }
} }
console.log(`** x_first`); console.log(`** ${mode}`);
demo(x_first); demo(data);
console.log(`** y_first`);
demo(y_first);
console.log(`** mixed`);
demo(mixed);
console.log(`** randomized`);
demo(randomized);
} }
doit(); let mode = String(process.argv[2]);
doit(mode);