var objA = {a:1, b:2, c:3, d:4};
var objB = {a:1, b:2, c:3, d:4};
delete objA.a;
delete objA.b;
delete objA.c;
delete objA.d;
objB.a = undefined;
objB.b = undefined;
objB.c = undefined;
objB.d = undefined;
function doNothing(objin){}
Object.entries(objA);
Object.entries(objB);
for(let a in objA) doNothing(a)
for(let b in objB) doNothing(b)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Deleted | |
Set undefined | |
Iterate deleted | |
Iterate set undefined |
Test name | Executions per second |
---|---|
Deleted | 17692076.0 Ops/sec |
Set undefined | 5162305.5 Ops/sec |
Iterate deleted | 115074440.0 Ops/sec |
Iterate set undefined | 44894736.0 Ops/sec |
Benchmark Overview
MeasureThat.net is a website where users can create and run JavaScript microbenchmarks to compare the performance of different approaches in various scenarios. The benchmark you provided tests four individual test cases:
Object.entries(objA)
after deleting properties from object objA
.Object.entries(objB)
after setting properties in object objB
to undefined
.objA
using a for...in
loop after deleting its properties.objB
using a for...in
loop after setting its properties to undefined
.Options Compared
The benchmark compares four options:
objA
before measuring the performance of Object.entries(objA)
.objB
to undefined
before measuring the performance of Object.entries(objB)
.Pros and Cons
undefined
, which is a common operation in JavaScript. However, it may not accurately represent real-world scenarios where objects are modified frequently.Library
In the benchmark preparation code, the following library is used:
Object.entries()
method is used, which is a built-in method of the Object
class.Special JS Features or Syntax
The benchmark uses the doNothing
function, which is defined in the script preparation code. However, there is no indication that this function does anything specific or special beyond simply not doing anything (hence the name).
Other Alternatives
To run this benchmark, you can create a new benchmark on MeasureThat.net and paste the provided JSON data into the "Benchmark Definition" field. You will also need to provide your own script preparation code, which should include the doNothing
function.
If you want to run similar benchmarks, you can try:
Object.keys()
or JSON.stringify()