Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String() vs .toString() vs template string with oids
(version: 2)
Comparing performance of:
toHexString vs toString vs String vs template literal
Created:
one month ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-bson/2.0.5/bson.min.js"></script>
Script Preparation code:
const N = 100; const oids = Array.from({ length: N }, () => new BSON.ObjectId()); const parsed = new Array(N); function fillParsed(transform) { for (let i = 0; i < N; i++) { parsed[i] = transform(oids[i]); } }
Tests:
toHexString
fillParsed(oid => oid.toHexString());
toString
fillParsed(oid => oid.toString());
String
fillParsed(oid => String(oid));
template literal
fillParsed(oid => `${oid}`);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
toHexString
toString
String
template literal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Browser/OS:
Chrome 146 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
toHexString
46625.6 Ops/sec
toString
47237.5 Ops/sec
String
36370.1 Ops/sec
template literal
24425.7 Ops/sec
Related benchmarks:
Object.entries VS Object.keys
Test to string lodash and js
Stor info in Array vs Object
Object.entries VS Object.values
Object.entries VS Object.values Perf
Object.keys Vs Object.entries Performance Test
Lodash DifferenceWith vs Native with Object
Object.entries vs for of
lodash _.some vs Array.some
Comments
Confirm delete:
Do you really want to delete benchmark?