Float64Array sort

Benchmark created on


Setup

const values = (new Array(2000)).fill(0).map(_ => Math.random())

const valuesF64 = new Float64Array(values)

const valuesF64_sorted = new Float64Array(values)

Test runner

Ready to run.

Testing in
TestOps/sec
normal toSorted
values.toSorted((a, b) => a - b)
ready
Float64 toSorted
return valuesF64.toSorted()
ready
normal filter + sort
let xx = values.filter(x => isFinite(x))
xx.sort((a, b) => a - b)
ready
Float64Array filter + sort
let xx = valuesF64.filter(x => x == x && x / 2 != x)
xx.sort()
ready
new Float64Array + sort
let xx = new Float64Array(values)
xx.sort()
ready
new Float64Array + sort manual filter
let xx = new Float64Array(values.length)
let xi = 0
for (let i = 0; i < values.length; i++) {
	if (Number.isFinite(values[i])) {
		xx[xi] = values[i]
		xi++
	}
}
xx = new Float64Array(xx.buffer, 0, xi)
xx.sort()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.