Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Integer variable vs integer in a single-element array
(version: 1)
Trying to avoid int/float conversion
Comparing performance of:
Raw int vs Array int vs ArrayBuf vs raw2
Created:
7 months ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
class Ints { #raw = 0 #arr = [0] #buf = new Uint32Array([0]) incrementRaw() { ++this.#raw; } incrementRaw2() { this.#raw = (this.#raw|0)+1; } incrementArr() { ++this.#arr[0]; } incrementBuf() { ++this.#buf[0]; } } globalThis.i = new Ints();
Tests:
Raw int
globalThis.i.incrementRaw();
Array int
globalThis.i.incrementArr();
ArrayBuf
globalThis.i.incrementBuf();
raw2
globalThis.i.incrementRaw2();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Raw int
Array int
ArrayBuf
raw2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Array int
356.8M/s
ArrayBuf
354.0M/s
raw2
184.1M/s
Raw int
167.8M/s
View exact numbers
Test name
Executions per second
✓
Array int
356,809,696 Ops/sec
ArrayBuf
353,990,752 Ops/sec
raw2
184,144,000 Ops/sec
Raw int
167,768,912 Ops/sec
Related benchmarks
Array constructor vs literal performance (10 items)
Array constructor vs literal performance (10_000 items)
Comments
Confirm delete:
Do you really want to delete benchmark?