Skip to content

Latest commit

 

History

History
755 lines (555 loc) · 35.4 KB

File metadata and controls

755 lines (555 loc) · 35.4 KB

Adding property

name ops/sec samples
Directly in the object 85,107,840 42559686
Using dot notation 75,180,168 37656450
Using define property (writable) 3,841,248 1920773
Using define property initialized (writable) 5,572,328 2787454
Using define property (getter) 2,067,297 1034840
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 20:49:19 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Array.append (number)

type amount time elapsed
array.push 10 0.011ms
new Array(length) 10 0.002ms
array.push 100 0.028ms
new Array(length) 100 0.01ms
array.push 1,000 0.041ms
new Array(length) 1,000 0.023ms
array.push 10,000 0.39ms
new Array(length) 10,000 0.142ms
array.push 1,000,000 27.155ms
new Array(length) 1,000,000 8.473ms
array.push 10,000,000 308.031ms
new Array(length) 10,000,000 52.517ms

Array.append (string)

type amount time elapsed
array.push 10 0.007ms
new Array(length) 10 0.018ms
array.push 100 0.012ms
new Array(length) 100 0.009ms
array.push 1,000 0.041ms
new Array(length) 1,000 0.02ms
array.push 10,000 0.256ms
new Array(length) 10,000 3.174ms
array.push 1,000,000 17.941ms
new Array(length) 1,000,000 12.262ms
array.push 10,000,000 229.995ms
new Array(length) 10,000,000 60.956ms

Array Creation

name ops/sec samples
new Array 232 117
Array.from 21 11
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 20:56:41 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Blob

name ops/sec samples
new Blob (128) 4,033 2019
new Blob (1024) 524 264
text (128) 47,144 23584
text (1024) 28,121 14070
arrayBuffer (128) 46,590 23296
arrayBuffer (1024) 32,584 16293
slice (0, 64) 89,004 46780
slice (0, 512) 51,607 26288
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:03:47 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Compression algorithms

name total time samples
Deflate 133.92 ms 1
Gzip 133.90 ms 1
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:07:47 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,715 3358
crypto.verify('RSA-SHA256') 6,787 3394
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:14:13 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Date toISOString

name ops/sec samples
new Date().toISOString() 2,664,742 1332508
fromUnixToISOString(new Date()) 2,115,938 1057971
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:16:53 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Date format MM/DD/YYYY

name ops/sec samples
Intl.DateTimeFormat().format(Date.now()) 18,236 9145
Intl.DateTimeFormat().format(new Date()) 17,634 8820
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(Date.now()) 18,207 9104
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(new Date()) 17,223 8825
Reusing Intl.DateTimeFormat() 352,442 176223
Date.toLocaleDateString() 688,039 344020
Date.toLocaleDateString(undefined, twoDigitsLocaleOptions) 21,451 10726
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:22:33 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Date String coersion

name ops/sec samples
Using String() 1,050,963 525483
Using brackets {} 1,052,623 526312
Using '' + 1,044,849 522425
Using date.toString() 1,144,181 572092
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:26:00 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Deleting properties

name ops/sec samples
Using delete property 3,314,461 1657483
Using delete property (proto: null) 18,368,072 9184037
Using delete property (cached proto: null) 3,326,971 1663868
Using undefined assignment 82,284,580 41152657
Using undefined assignment (proto: null) 20,728,909 10366216
Using undefined property (cached proto: null) 80,831,180 40415636
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:29:24 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Node.js Error

name ops/sec samples
Error 295,088 147545
NodeError 277,167 138601
NodeError Range 261,261 130669
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:35:17 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 71,357,583 35680449
using Array.includes (first item) 85,662,012 42863838
Using raw comparison 100,160,207 50082242
Using raw comparison (first item) 105,396,526 52703079
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:40:08 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 46,883,462 23441871
Using Object.getOwnPropertyNames() 47,344,113 23675580
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:42:43 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 21,256,550 10634102
Length = 10_000 - Array.at 21,438,171 10719091
Length = 1_000_000 - Array.at 20,769,939 10384975
Length = 100 - Array[length - 1] 97,863,921 48931974
Length = 10_000 - Array[length - 1] 98,556,787 49283687
Length = 1_000_000 - Array[length - 1] 100,005,561 50006743
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:46:10 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Math.floor vs ~

name ops/sec samples
Math.floor (small) 104,881,513 52454518
~ (small) 106,256,392 53173834
Math.floor (long) 105,266,415 52646415
~ (long) 107,192,097 53599276
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:51:25 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Object Creation

name ops/sec samples
Object.create(null) 36,851,731 18438604
Object.create({}) 1,325,559 665091
new Function with empty prototype 82,090,781 41045894
Empty class 84,026,883 42033955
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 21:54:18 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 92,356,036 46178028
Using parseInt(x, 10) - big number (10 len) 16,853,749 8436980
Using + - small number (2 len) 99,135,427 50006241
Using + - big number (10 len) 105,128,308 52564163
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:00:03 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Possible undefined Function

name ops/sec samples
Using if to check function existence 694,158 352180
Using ? operator to avoid rejection 737,803 368922
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:02:23 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Private Property

name ops/sec samples
Raw usage private field 83,749,875 41882260
Raw usage underscore usage 84,414,687 42249145
Manipulating private properties using # 80,664,368 40337234
Manipulating private properties using underscore(_) 80,654,545 40337113
Manipulating private properties using Symbol 76,536,188 38268149
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:08:48 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 3,762,785 1881394
Adding property in the object creation - small object 3,774,501 1888554
Adding property after the function creation - small class 193,249 96625
Adding property in the function creation - small class 195,703 97852
Adding property after the class creation - small class 161,107 80554
Adding property in the class creation - small class 163,989 84194
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:13:23 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Property Getter Access

name ops/sec samples
Getter (class) 105,983,193 52991611
Getter 55,708,142 27855728
Method 105,495,760 52825342
DefineProperty (getter) 93,687,835 46843931
DefineProperty (getter & enumerable=false) 53,908,815 26954415
DefineProperty (getter & configurable=false) 107,041,764 53520918
DefineProperty (getter & enumerable=false & configurable=false) 57,112,272 28556145
DefineProperty (writable) 105,776,167 52890579
DefineProperty (writable & enumerable=false) 106,490,572 53246207
DefineProperty (writable & enumerable=false & configurable=false) 105,214,187 52607106
DefineProperties (getter) 52,065,758 26032886
DefineProperties (getter & enumerable=false) 55,699,163 27849599
DefineProperties (getter & enumerable=false & configurable=false) 56,428,540 28214301
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:15:57 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Property Setter Access

name ops/sec samples
Setter (class) 102,027,089 51013553
Setter 10,923,129 5461847
Method 103,129,230 51570615
DefineProperty (setter) 98,039,892 49020594
DefineProperty (setter & enumerable=false) 10,865,104 5438602
DefineProperty (setter & configurable=false) 10,981,515 5490762
DefineProperty (setter & enumerable=false & configurable=false) 10,969,224 5484614
DefineProperty (writable) 101,169,486 50589527
DefineProperty (writable & enumerable=false) 100,314,850 50157439
DefineProperty (writable & enumerable=false & configurable=false) 101,102,314 50556390
DefineProperties (setter) 98,725,793 49368133
DefineProperties (setter & enumerable=false) 10,662,406 5331207
DefineProperties (setter & enumerable=false & configurable=false) 11,024,061 5512217
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:21:46 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

replace vs replaceAll comparison

name ops/sec samples
Using replace(//g) 3,360,501 1680736
Using replaceAll() 2,998,966 1499939
Using replaceAll(//g) 2,987,518 1494086
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:26:58 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Shallow Copy

name ops/sec samples
{ ...object } 21,083,123 10546933
{ ...object, proto: null } 21,567,109 10790088
{ ...object, newProp: true } 614,935 309756
structuredClone 251,782 125959
JSON.parse + JSON.stringify 193,456 96732
loop + object.keys starting with {} 1,276,226 638122
loop + object.keys starting with { proto: null } 708,865 354434
loop + object.keys starting with { randomProp: true } 515,127 257677
object.keys + reduce(FN, {}) 1,290,403 645369
object.keys + reduce(FN, { proto: null }) 726,650 363328
object.keys + reduce(FN, { newProp: true }) 506,352 253179
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:32:42 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Sorting Map

name ops/sec samples
Sort using default 262,442 131308
Sort using first char 1,261,680 630916
Sort using localeCompare 1,159,046 579654
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:36:24 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 1,760 881
{...smallObject} - Total keys: 2 41,014,726 20515006
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 1,049 526
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,270 3136
{ ...bigObject, ...anotherBigObject } 1,107 554
Object.assign({}, smallObject, anotherSmallObject) - creating new object 11,931,381 5965694
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 27,565,057 13783084
{ ...smallObject, ...anotherSmallObject } 19,262,032 9631101
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:39:45 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Stream.Readable

name ops/sec samples
streams.Readable reading 1e3 * "some data" 2,205 1109
streams.web.Readable reading 1e3 * "some data" 563 282
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:45:23 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Stream.Writable

name ops/sec samples
streams.Writable writing 1e3 * "some data" 5,210 2606
streams.web.WritableStream writing 1e3 * "some data" 1,697 849
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:49:26 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

String concat

name ops/sec samples
Using + sign 99,745,078 50117025
Using backtick (`) 100,296,842 50148440
Using array.join 10,582,667 5292647
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:52:42 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 52,771,616 26385818
(short string) (true) String#slice and strict comparison 51,278,896 25639461
(long string) (true) String#endsWith 50,891,579 25445800
(long string) (true) String#slice and strict comparison 44,658,350 22332079
(short string) (false) String#endsWith 57,494,338 28747177
(short string) (false) String#slice and strict comparison 61,022,505 30511288
(long string) (false) String#endsWith 56,024,351 28014131
(long string) (false) String#slice and strict comparison 52,880,943 26440484
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 22:58:55 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

String searching

name ops/sec samples
Using includes 16,115,427 8058966
Using indexof 16,189,176 8094790
Using RegExp.test 14,013,296 7006696
Using RegExp.text with cached regex pattern 14,733,112 7367104
Using new RegExp.test 4,325,937 2163362
Using new RegExp.test with cached regex pattern 4,898,595 2449768
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 23:02:08 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 70,811,928 35405973
(short string) (true) String#slice and strict comparison 50,895,419 25447717
(long string) (true) String#startsWith 55,473,518 27736770
(long string) (true) String#slice and strict comparison 44,924,520 22468265
(short string) (false) String#startsWith 102,391,435 51195748
(short string) (false) String#slice and strict comparison 60,988,856 30494453
(long string) (false) String#startsWith 88,901,242 44450647
(long string) (false) String#slice and strict comparison 52,882,880 26446769
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 23:05:56 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Super vs This

name ops/sec samples
Using super 85,496,509 42970275
Using this 89,922,713 44961417
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 23:09:28 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8

Getting unix time

name ops/sec samples
new Date().getTime() 8,939,173 4469589
Date.now() 16,850,283 8436574
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Wed Oct 15 2025 23:13:13 GMT+0000 (Coordinated Universal Time)
  • Node: v18.20.8