Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Fastest way to check if object is empty with 3 types of checks with big amount of data
(version: 0)
You don't need to make add for loops in your test scenarios, the benchmark does it itself.
Comparing performance of:
object.keys() vs JSON.stringify() vs iterate over props
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var xxx = { '0': { 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } }, 'AAA': { '1': { '2': [ 'AAA' ], '3': [ 'AAA' ] } } } }
Tests:
object.keys()
Object.keys(xxx) === 0
JSON.stringify()
JSON.stringify(xxx) === "{}"
iterate over props
let isEmpty = true; for (const key in xxx) { isEmpty = false; break; } return isEmpty;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
object.keys()
JSON.stringify()
iterate over props
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0
Browser/OS:
Chrome 123 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
object.keys()
6483139.5 Ops/sec
JSON.stringify()
1498514.1 Ops/sec
iterate over props
8856006.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're describing the output of a tool or test suite that generates benchmarks for JavaScript code. Based on the provided data, I'll attempt to provide some insights: 1. **Individual test cases**: The first section lists three test cases: * `object.keys()`: Verifies if the `Object.keys()` method returns an empty array when applied to an object. * `JSON.stringify()`: Verifies if the `JSON.stringify()` method returns a string equal to `{}` when applied to an object. * `iterate over props`: Verifies if iterating over an object's properties using a `for...in` loop sets a flag (`isEmpty`) to `true` if no properties are found. Note that this test case seems slightly unusual, as the flag is set to `false` on the first iteration. 2. **Latest benchmark result**: The second section presents three benchmarking results: * Each result includes information about the browser version, device platform, operating system, and execution rate per second (e.g., "ExecutionsPerSecond": 8856006.0). * These results likely indicate the performance of each test case under different conditions. To provide a more specific answer, I would need more context or details about what these benchmarks are measuring or how they relate to the code being tested.
Related benchmarks:
Loop perf
object to array with lodash
IndexOf vs Includes vs hash vs set
Hash vs insert
reassigning an object with larger arrray
Comments
Confirm delete:
Do you really want to delete benchmark?