Script Preparation code:
x
 
var xxx = {}
var yyy = {};
for (let i = 0; i < 10; ++i) {
  yyy[`key${i}`] = i;
}
function isEmpty(v) {
  for (const _ in xxx) { return false }
  return true;
}
Tests:
  • object.keys()

     
    Object.keys(xxx) === 0
    Object.keys(yyy) === 0
  • JSON.stringify()

     
    JSON.stringify(xxx) === "{}"
    JSON.stringify(yyy) === "{}"
  • for in

     
    isEmpty(xxx);
    isEmpty(yyy);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    object.keys()
    JSON.stringify()
    for in

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
Chrome 120 on Windows
View result in a separate tab
Test name Executions per second
object.keys() 3794875.0 Ops/sec
JSON.stringify() 1298410.6 Ops/sec
for in 3688980.0 Ops/sec