add nota benchmark; builds no longer continue on test fail
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -79,7 +79,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Test Prosperon
|
- name: Test Prosperon
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
continue-on-error: true
|
|
||||||
env:
|
env:
|
||||||
TRACY_NO_INVARIANT_CHECK: 1
|
TRACY_NO_INVARIANT_CHECK: 1
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
76
benchmarks/nota.js
Normal file
76
benchmarks/nota.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
var nota = use('nota')
|
||||||
|
var os = use('os')
|
||||||
|
var io = use('io')
|
||||||
|
|
||||||
|
var ll = io.slurp('benchmarks/nota.json')
|
||||||
|
|
||||||
|
var newarr = []
|
||||||
|
var accstr = ""
|
||||||
|
for (var i = 0; i < 10000; i++) {
|
||||||
|
accstr += i;
|
||||||
|
newarr.push(i.toString())
|
||||||
|
}
|
||||||
|
// Arrays to store timing results
|
||||||
|
var jsonDecodeTimes = [];
|
||||||
|
var jsonEncodeTimes = [];
|
||||||
|
var notaEncodeTimes = [];
|
||||||
|
var notaDecodeTimes = [];
|
||||||
|
var notaSizes = [];
|
||||||
|
|
||||||
|
// Run 100 tests
|
||||||
|
for (let i = 0; i < 100; i++) {
|
||||||
|
// JSON Decode test
|
||||||
|
let start = os.now();
|
||||||
|
var jll = json.decode(ll);
|
||||||
|
jsonDecodeTimes.push((os.now() - start) * 1000);
|
||||||
|
|
||||||
|
// JSON Encode test
|
||||||
|
start = os.now();
|
||||||
|
let jsonStr = JSON.stringify(jll);
|
||||||
|
jsonEncodeTimes.push((os.now() - start) * 1000);
|
||||||
|
|
||||||
|
// NOTA Encode test
|
||||||
|
start = os.now();
|
||||||
|
var nll = nota.encode(jll);
|
||||||
|
notaEncodeTimes.push((os.now() - start) * 1000);
|
||||||
|
|
||||||
|
// NOTA Decode test
|
||||||
|
start = os.now();
|
||||||
|
var oll = nota.decode(nll);
|
||||||
|
notaDecodeTimes.push((os.now() - start) * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate statistics
|
||||||
|
function getStats(arr) {
|
||||||
|
const avg = arr.reduce((a, b) => a + b) / arr.length;
|
||||||
|
const min = Math.min(...arr);
|
||||||
|
const max = Math.max(...arr);
|
||||||
|
return { avg, min, max };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pretty print results
|
||||||
|
console.log("\n=== Performance Test Results (100 iterations) ===");
|
||||||
|
console.log("\nJSON Decoding (ms):");
|
||||||
|
const jsonDecStats = getStats(jsonDecodeTimes);
|
||||||
|
console.log(`Average: ${jsonDecStats.avg.toFixed(2)} ms`);
|
||||||
|
console.log(`Min: ${jsonDecStats.min.toFixed(2)} ms`);
|
||||||
|
console.log(`Max: ${jsonDecStats.max.toFixed(2)} ms`);
|
||||||
|
|
||||||
|
console.log("\nJSON Encoding (ms):");
|
||||||
|
const jsonEncStats = getStats(jsonEncodeTimes);
|
||||||
|
console.log(`Average: ${jsonEncStats.avg.toFixed(2)} ms`);
|
||||||
|
console.log(`Min: ${jsonEncStats.min.toFixed(2)} ms`);
|
||||||
|
console.log(`Max: ${jsonEncStats.max.toFixed(2)} ms`);
|
||||||
|
|
||||||
|
console.log("\nNOTA Encoding (ms):");
|
||||||
|
const notaEncStats = getStats(notaEncodeTimes);
|
||||||
|
console.log(`Average: ${notaEncStats.avg.toFixed(2)} ms`);
|
||||||
|
console.log(`Min: ${notaEncStats.min.toFixed(2)} ms`);
|
||||||
|
console.log(`Max: ${notaEncStats.max.toFixed(2)} ms`);
|
||||||
|
|
||||||
|
console.log("\nNOTA Decoding (ms):");
|
||||||
|
const notaDecStats = getStats(notaDecodeTimes);
|
||||||
|
console.log(`Average: ${notaDecStats.avg.toFixed(2)} ms`);
|
||||||
|
console.log(`Min: ${notaDecStats.min.toFixed(2)} ms`);
|
||||||
|
console.log(`Max: ${notaDecStats.max.toFixed(2)} ms`);
|
||||||
|
|
||||||
2132
benchmarks/nota.json
Normal file
2132
benchmarks/nota.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user