Run details:
Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Chrome OS 14541.0.0
Desktop
15 days ago
Test name Executions per second
Normal 45365668.0 Ops/sec
1 with statement 1859805.2 Ops/sec
2 with statements 1094624.8 Ops/sec
3 with statements 694999.0 Ops/sec
4 with statements 569987.9 Ops/sec
Script Preparation code:
AخA
 
let smthg = {abc:123}
let myObj = {property: 1000}
myObj.myObj = myObj
for(let i = 5; i--;) window[`go${i}`] = Function(`with(myObj)`.repeat(i)+`{vari = 456; smthg = 789}`)
Tests:
  • Normal

     
    go0()
  • 1 with statement

     
    go1()
  • 2 with statements

     
    go2()
  • 3 with statements

     
    go3()
  • 4 with statements

     
    go4()