Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Unique Instance Test
(version: 4)
Unique Instance Test
Comparing performance of:
Standard Instance vs Unique Instance by key
Created:
5 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const N = 1<<16; const getInt = (()=>{r=Math.random;f=Math.floor;return (a=0,b=0x100000000)=>f(r()*(b-a))+a})(); const getStr = (()=>{ const f = (n)=> n < 10 ? 0x30 + n : n < 36 ? 0x41 + (n - 10) : 0x61 + (n - 36); return (n)=> String.fromCharCode(...(new Int32Array(n)).map(()=>f(getInt(0,62)))); })(); const createInstance = (str)=>{ return { str, val : getInt() }; }
Tests:
Standard Instance
let list = new Array(N); const getInstance = (value)=>createInstance(value) for(i=0;i<N;i++) list[i] = getInstance(getStr(1));
Unique Instance by key
let list = new Array(N); let refs = {}; const getInstance = (value)=>{ if(refs[value]) return refs[value]; return refs[value] = createInstance(value); } for(i=0;i<N;i++) list[i] = getInstance(getStr(1));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Standard Instance
Unique Instance by key
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Standard Instance
286.7 Ops/sec
Unique Instance by key
224.6 Ops/sec
Related benchmarks:
Object vs Map
bigint-vs-string
yoooooo
JavaScript String Starts/Ends With String Comparisons - Playground
JavaScript Checking That A String Starts With A Value - A Value Is Found - Benchmarks - Playground
JavaScript Checking That A String Starts With A Value - Value Is **NOT** Found - Benchmarks - Playground
Mappers
Checking array equality
Member Access Object vs Map(string key) vs Map(object key)
Comments
Confirm delete:
Do you really want to delete benchmark?