Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
(new)? DataView or BitTwiddling for Reads
(version: 1)
Is DataView faster than directly bit twiddling?
Comparing performance of:
Bit Twiddling, Aligned vs DataView, Aligned vs new DataView, Aligned
Created:
8 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
let buf = new ArrayBuffer(12); u32s = new Uint32Array(buf); u8s = new Uint8Array(buf); dv = new DataView(buf); offset = 0; sum = 0;
Tests:
Bit Twiddling, Aligned
sum += ((u8s[offset] << 24) | (u8s[offset + 1] << 16) | (u8s[offset + 2] << 8) | u8s[offset + 3]) | 0;
DataView, Aligned
sum += dv.getInt32(offset, false);
new DataView, Aligned
sum += (new DataView(buf)).getInt32(offset, false);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Bit Twiddling, Aligned
DataView, Aligned
new DataView, Aligned
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Bit Twiddling, Aligned
13185924.0 Ops/sec
DataView, Aligned
13292502.0 Ops/sec
new DataView, Aligned
9795018.0 Ops/sec
Related benchmarks:
DataView vs Uint8Array by bytes
DataView vs Uint8Array (read bytes)
DataView vs Uint8Array by bytes vs Native Array
DataView vs Uint32Array debunking myth
DataView vs Uint8Array by bytes vs Uint8Array set Uint8Array vs DataView loop
DataView or BitTwiddling, Aligned and Unaligned
DataView or BitTwiddling for Reads
Binary to boolean with DataView: readUint8() with for loop vs. slice() with map()
uint32 DataView vs Direct Calculate
Comments
Confirm delete:
Do you really want to delete benchmark?