function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
var a = [Array(10000)].map(_ => Math.random(1000000));
var ta = (new Float64Array(10000)).map(_ => Math.random(1000000));
a.slice(0);
ta.slice(0);
for (let i = 0; i < 10000; ++i) {
a[i] = a[i] + 1;
}
for (let i = 0; i < 10000; ++i) {
ta[i] = ta[i] + 1;
}
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
array slice | |
typedArray slice | |
array i/o | |
typedArray i/o |
Test name | Executions per second |
---|---|
array slice | 32700.3 Ops/sec |
typedArray slice | 37947.1 Ops/sec |
array i/o | 114456.4 Ops/sec |
typedArray i/o | 193541.1 Ops/sec |
Overview
The provided JSON represents a benchmark test case created on MeasureThat.net, a website where users can create and run JavaScript microbenchmarks. The test compares the performance of arrays and TypedArrays in various operations.
Benchmark Definition
The benchmark definition is represented by two JSON objects:
Test Cases
There are four individual test cases:
**: Tests the performance of slicing arrays using the
slice()` method.**: Tests the performance of slicing TypedArrays using the
slice()` method.Options Compared
The benchmark compares two options:
Library Usage
In the provided benchmark definition, no external libraries are used. However, in some test cases, JavaScript built-in functions like Array.prototype.slice()
and Float64Array
are used.
Special JS Features or Syntax
No special JavaScript features or syntax (e.g., async/await, promises) are used in this benchmark. The focus is on comparing the performance of arrays and TypedArrays.
Other Alternatives
If you need to create similar benchmarks for other operations or data structures, consider using MeasureThat.net's website or alternatives like:
micro-benchmark
or Benchmark.js
jsperf
(now deprecated) or Mozilla's SpiderMonkey Tuner
Keep in mind that each platform has its strengths and weaknesses, and some might be better suited for your specific use case.