Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Sorting small integers: Array vs various TypedArray types performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.prototype.sort
133.9 Ops/sec
Int32Array.prototype.sort
348.9 Ops/sec
Float32Array.prototype.sort
49.0 Ops/sec
Float64Array.prototype.sort
55.5 Ops/sec
Script Preparation code:
const ELEMENT_COUNT = 1_000_000; const INT_VALUE_MIN = 0; const INT_VALUE_MAX = 2 ** 15 - 1; const array = new Array(ELEMENT_COUNT); const int16array = new Int16Array(ELEMENT_COUNT); const uint16array = new Uint16Array(ELEMENT_COUNT); const int32array = new Int32Array(ELEMENT_COUNT); const uint32array = new Uint32Array(ELEMENT_COUNT); const float32array = new Float32Array(ELEMENT_COUNT); const float64array = new Float64Array(ELEMENT_COUNT); const bigint64array = new BigInt64Array(ELEMENT_COUNT); const biguint64array = new BigUint64Array(ELEMENT_COUNT); for (let i = 0; i < ELEMENT_COUNT; i++) { const value = INT_VALUE_MIN + Math.floor(Math.random() * INT_VALUE_MAX); array[i] = value; int16array[i] = value; uint16array[i] = value; int32array[i] = value; uint32array[i] = value; float32array[i] = value; float64array[i] = value; bigint64array[i] = BigInt(value); biguint64array[i] = BigInt(value); } const comparator = (a, b) => a - b;
Tests:
Array.prototype.sort
array.sort(comparator);
Int16Array.prototype.sort
int16array.sort();
Uint16Array.prototype.sort
uint16array.sort();
Int32Array.prototype.sort
int32array.sort();
Uint32Array.prototype.sort
uint32array.sort();
Float32Array.prototype.sort
float32array.sort();
Float64Array.prototype.sort
float64array.sort();
BigInt64Array.prototype.sort
bigint64array.sort();
BigUint64Array.prototype.sort
biguint64array.sort();