MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

update bench.js to allow arguments

+27 -6
+27 -6
tests/bench.js
··· 575 575 for (i = 0; i < 500; i++) { 576 576 x = (x << BigInt(3)) - BigInt(7); 577 577 y += x >> BigInt(5); 578 - y += (-x) >> BigInt(7); 578 + y += -x >> BigInt(7); 579 579 } 580 580 } 581 581 global_res = x + y; ··· 931 931 f.close(); 932 932 } 933 933 934 + function get_cli_args(argc, argv) { 935 + if (argv && argc > 0) return Array.prototype.slice.call(argv, 1, argc); 936 + if (typeof process !== 'undefined' && process && process.argv) return process.argv.slice(2); 937 + return []; 938 + } 939 + 934 940 function main(argc, argv, g) { 935 941 var test_list = [ 936 942 empty_loop, ··· 979 985 string_to_float 980 986 ]; 981 987 var tests = []; 982 - var i, j, n, f, name, found; 988 + var args = get_cli_args(argc, argv); 989 + var i, j, n, f, name, found, exact; 983 990 984 991 if (typeof BigInt == 'function') { 985 992 /* BigInt test */ ··· 988 995 test_list.push(bigint_shift_floor); 989 996 } 990 997 991 - for (i = 1; i < argc; ) { 992 - name = argv[i++]; 998 + for (i = 0; i < args.length; ) { 999 + name = args[i++]; 993 1000 if (name == '-a') { 994 1001 sort_bench.verbose = true; 995 1002 continue; 996 1003 } 997 1004 if (name == '-t') { 998 - name = argv[i++]; 1005 + name = args[i++]; 999 1006 sort_bench.array_type = g[name]; 1000 1007 if (typeof sort_bench.array_type != 'function') { 1001 1008 console.log('unknown array type: ' + name); ··· 1004 1011 continue; 1005 1012 } 1006 1013 if (name == '-n') { 1007 - sort_bench.array_size = +argv[i++]; 1014 + sort_bench.array_size = +args[i++]; 1015 + continue; 1016 + } 1017 + 1018 + exact = null; 1019 + for (j = 0; j < test_list.length; j++) { 1020 + f = test_list[j]; 1021 + if (f.name === name) { 1022 + exact = f; 1023 + break; 1024 + } 1025 + } 1026 + if (exact) { 1027 + tests.push(exact); 1008 1028 continue; 1009 1029 } 1030 + 1010 1031 for (j = 0, found = false; j < test_list.length; j++) { 1011 1032 f = test_list[j]; 1012 1033 if (f.name.slice(0, name.length) === name) {