Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
IP dotted decimal to number
(version: 1)
Comparing performance of:
bitwise shift vs ParseInt vs POW
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const ip = '222.212.77.30';
Tests:
bitwise shift
const octets = ip.split('.').map(Number); return (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | octets[3];
ParseInt
const octets = ip.split('.'); return ( (parseInt(octets[0]) << 24) | (parseInt(octets[1]) << 16) | (parseInt(octets[2]) << 8) | parseInt(octets[3]) );
POW
const octets = ip.split('.'); return ( (parseInt(octets[0]) * Math.pow(256, 3)) + (parseInt(octets[1]) * Math.pow(256, 2)) + (parseInt(octets[2]) * Math.pow(256, 1)) + (parseInt(octets[3]) * Math.pow(256, 0)) );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
bitwise shift
ParseInt
POW
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 126 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
bitwise shift
5778916.0 Ops/sec
ParseInt
9470362.0 Ops/sec
POW
8453131.0 Ops/sec
Related benchmarks:
Is odd
int int int
Math floor vs | vs shift
multiplication vs parseInt vs Number vs bitwise
Parse 32-bit hex | BigInt vs regex + parseInt
parseInt vs
Is odd (large)
Is odd (large float)
multiplication vs parseInt vs Number vs bitwise vs unary
Comments
Confirm delete:
Do you really want to delete benchmark?