Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object Values Filtering
(version: 1)
Comparing performance of:
[key] vs truthy and [key] vs in vs truthy and in vs not null and in
Created:
6 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
datasets = { trailer: {}, location: {} }, uuidv4 = () => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }, count = 10000 for(let step = 0; step < 1000; step++){ const location = { uuid: uuidv4(), number: Math.random(), number1: Math.random(), number2: Math.random(), number3: Math.random(), number4: Math.random() } datasets.location[location.uuid] = location } for(let step = 0; step < count; step++ ){ const trailer = { uuid: uuidv4(), number: Math.random(), number1: Math.random(), number2: Math.random(), number3: Math.random(), number4: Math.random(), number5: Math.random(), number6: Math.random(), number7: Math.random(), number8: Math.random(), number9: Math.random(), number10: Math.random(), number11: Math.random(), number12: Math.random(), number13: Math.random(), number14: Math.random(), number15: Math.random(), location: step%10 == 0 ? Object.keys(datasets.location)[Math.random()*100|0] : null } datasets.trailer[trailer.uuid] = trailer } trailers = Object.values(datasets.trailer)
Tests:
[key]
trailers.filter(trailer => datasets.location[trailer.location])
truthy and [key]
trailers.filter(trailer => trailer.location && datasets.location[trailer.location])
in
trailers.filter(trailer => trailer.location in datasets.location)
truthy and in
trailers.filter(trailer => trailer.location && trailer.location in datasets.location)
not null and in
trailers.filter(trailer => trailer.location !== null && trailer.location in datasets.location)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
[key]
truthy and [key]
in
truthy and in
not null and in
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
[sited] Lodash vs native map
[sited] Lodash vs native filter
Set string vs number
Set string vs number #1
Comments
Confirm delete:
Do you really want to delete benchmark?