mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
Each bench program gets an equivalent, differently written variant in bench/variants/, run next to its original on both implementations, with the variant / original ratio per side. A plugin-event benchmark runs the conformance reducer with a git.status tool as a 226-byte and a 3 KB source. RESULTS.md labels medians, mins and means, computes speed-ups from medians only, and notes that the reference tools validate through Effect Schema.
19 lines
510 B
JavaScript
19 lines
510 B
JavaScript
const COUNT = 5e4
|
|
const values = Array.from({ length: COUNT }, function (unused, idx) {
|
|
return (7919 * idx) % COUNT
|
|
})
|
|
function twice(v) {
|
|
return v + v
|
|
}
|
|
const kept = values.map(twice).filter(function (v) {
|
|
return v % 3 != 0
|
|
})
|
|
const sum = kept.reduce(function (acc, v) {
|
|
return acc + v
|
|
}, 0)
|
|
function ascending(left, right) {
|
|
return left < right ? -1 : left > right ? 1 : 0
|
|
}
|
|
const ordered = kept.slice(0, 2e4).sort(ascending)
|
|
const last = ordered.length - 1
|
|
return [sum, ordered[0], ordered[last]]
|