Skip to content

Latest commit

 

History

History
755 lines (555 loc) · 35.3 KB

File metadata and controls

755 lines (555 loc) · 35.3 KB

Adding property

name ops/sec samples
Directly in the object 89,238,029 44620971
Using dot notation 63,624,208 31855939
Using define property (writable) 4,764,241 2382122
Using define property initialized (writable) 7,050,322 3528097
Using define property (getter) 2,419,700 1209851
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:11:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Array.append (number)

type amount time elapsed
array.push 10 0.005ms
new Array(length) 10 0.002ms
array.push 100 0.032ms
new Array(length) 100 0.013ms
array.push 1,000 0.038ms
new Array(length) 1,000 0.021ms
array.push 10,000 0.342ms
new Array(length) 10,000 0.14ms
array.push 1,000,000 31.779ms
new Array(length) 1,000,000 7.626ms
array.push 10,000,000 262.749ms
new Array(length) 10,000,000 69.69ms

Array.append (string)

type amount time elapsed
array.push 10 0.004ms
new Array(length) 10 0.004ms
array.push 100 0.017ms
new Array(length) 100 0.013ms
array.push 1,000 0.037ms
new Array(length) 1,000 0.02ms
array.push 10,000 0.353ms
new Array(length) 10,000 0.119ms
array.push 1,000,000 18.15ms
new Array(length) 1,000,000 11.164ms
array.push 10,000,000 224.835ms
new Array(length) 10,000,000 65.885ms

Array Creation

name ops/sec samples
new Array 260 132
Array.from 22 12
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:19:04 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Blob

name ops/sec samples
new Blob (128) 4,377 2208
new Blob (1024) 579 294
text (128) 4,156 2084
text (1024) 514 258
arrayBuffer (128) 4,078 2041
arrayBuffer (1024) 512 257
slice (0, 64) 148,771 81994
slice (0, 512) 31,803 15910
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:25:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Compression algorithms

name total time samples
Deflate 134.19 ms 1
Gzip 135.62 ms 1
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:33:20 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,804 3403
crypto.verify('RSA-SHA256') 6,833 3417
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:41:54 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Date toISOString

name ops/sec samples
new Date().toISOString() 1,212,236 606186
fromUnixToISOString(new Date()) 2,154,696 1095128
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:43:18 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Date format MM/DD/YYYY

name ops/sec samples
Intl.DateTimeFormat().format(Date.now()) 20,571 10286
Intl.DateTimeFormat().format(new Date()) 20,122 10067
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(Date.now()) 19,799 9900
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(new Date()) 18,987 9494
Reusing Intl.DateTimeFormat() 643,910 322113
Date.toLocaleDateString() 1,106,925 553464
Date.toLocaleDateString(undefined, twoDigitsLocaleOptions) 24,634 12318
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:50:30 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Date String coersion

name ops/sec samples
Using String() 900,461 450282
Using brackets {} 896,553 448278
Using '' + 897,772 448981
Using date.toString() 975,127 487694
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 17:55:15 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Deleting properties

name ops/sec samples
Using delete property 4,017,764 2009144
Using delete property (proto: null) 17,460,846 8730636
Using delete property (cached proto: null) 4,018,646 2009683
Using undefined assignment 75,383,320 37691765
Using undefined assignment (proto: null) 19,465,831 9732917
Using undefined property (cached proto: null) 75,492,084 37746048
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:00:26 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Node.js Error

name ops/sec samples
Error 334,673 167339
NodeError 311,394 155699
NodeError Range 302,886 151445
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:04:04 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 65,531,218 32765636
using Array.includes (first item) 77,987,443 38995587
Using raw comparison 88,621,782 44310908
Using raw comparison (first item) 92,772,743 46386402
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:11:01 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 41,506,068 20753095
Using Object.getOwnPropertyNames() 42,590,254 21295133
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:14:02 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 93,835,852 46955033
Length = 10_000 - Array.at 93,061,999 46531245
Length = 1_000_000 - Array.at 96,117,218 48058621
Length = 100 - Array[length - 1] 93,953,299 46976675
Length = 10_000 - Array[length - 1] 89,280,026 44640068
Length = 1_000_000 - Array[length - 1] 93,626,842 46817380
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:20:02 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Math.floor vs ~

name ops/sec samples
Math.floor (small) 97,195,406 48619251
~ (small) 97,206,396 48608035
Math.floor (long) 97,325,993 48663011
~ (long) 97,185,638 48592839
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:23:59 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Object Creation

name ops/sec samples
Object.create(null) 28,380,783 14197620
Object.create({}) 2,095,689 1063926
new Function with empty prototype 74,722,411 37375367
Empty class 73,890,771 36948303
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:28:11 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 97,281,732 48640873
Using parseInt(x, 10) - big number (10 len) 97,132,358 48568415
Using + - small number (2 len) 96,970,077 48490574
Using + - big number (10 len) 96,749,181 48386252
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:33:41 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Possible undefined Function

name ops/sec samples
Using if to check function existence 1,036,301 528042
Using ? operator to avoid rejection 1,089,873 551322
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:38:01 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Private Property

name ops/sec samples
Raw usage private field 90,204,453 45103111
Raw usage underscore usage 92,102,421 46051226
Manipulating private properties using # 94,478,159 47239092
Manipulating private properties using underscore(_) 94,769,581 47384798
Manipulating private properties using Symbol 94,034,896 47017459
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:40:29 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 7,827,549 3913779
Adding property in the object creation - small object 7,817,376 3908690
Adding property after the function creation - small class 279,115 139558
Adding property in the function creation - small class 290,782 145396
Adding property after the class creation - small class 272,931 138188
Adding property in the class creation - small class 274,033 140347
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:46:38 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Property Getter Access

name ops/sec samples
Getter (class) 96,978,760 48536559
Getter 48,820,822 24418544
Method 94,319,549 47179200
DefineProperty (getter) 97,094,009 48549310
DefineProperty (getter & enumerable=false) 50,034,705 25019175
DefineProperty (getter & configurable=false) 97,454,692 48728089
DefineProperty (getter & enumerable=false & configurable=false) 48,046,932 24033189
DefineProperty (writable) 91,928,259 45964554
DefineProperty (writable & enumerable=false) 97,437,896 48725474
DefineProperty (writable & enumerable=false & configurable=false) 89,603,850 44806935
DefineProperties (getter) 49,841,606 24932019
DefineProperties (getter & enumerable=false) 49,868,304 24936383
DefineProperties (getter & enumerable=false & configurable=false) 50,060,452 25043179
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:54:05 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Property Setter Access

name ops/sec samples
Setter (class) 96,511,273 48255846
Setter 11,536,086 5769325
Method 88,337,249 44169492
DefineProperty (setter) 95,271,421 47794785
DefineProperty (setter & enumerable=false) 11,655,142 5828435
DefineProperty (setter & configurable=false) 11,498,724 5749634
DefineProperty (setter & enumerable=false & configurable=false) 11,438,430 5719218
DefineProperty (writable) 96,560,226 48287732
DefineProperty (writable & enumerable=false) 95,612,288 47810045
DefineProperty (writable & enumerable=false & configurable=false) 97,688,638 48845294
DefineProperties (setter) 95,683,797 47841968
DefineProperties (setter & enumerable=false) 11,551,361 5777420
DefineProperties (setter & enumerable=false & configurable=false) 11,518,938 5760307
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 18:58:58 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

replace vs replaceAll comparison

name ops/sec samples
Using replace(//g) 3,234,692 1617668
Using replaceAll() 3,066,371 1540401
Using replaceAll(//g) 2,978,072 1489039
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:03:13 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Shallow Copy

name ops/sec samples
{ ...object } 24,862,128 12431067
{ ...object, proto: null } 2,474,418 1237210
{ ...object, newProp: true } 22,591,347 11297778
structuredClone 284,127 142091
JSON.parse + JSON.stringify 293,720 146906
loop + object.keys starting with {} 1,673,342 836709
loop + object.keys starting with { proto: null } 844,304 422153
loop + object.keys starting with { randomProp: true } 620,512 310313
object.keys + reduce(FN, {}) 1,714,301 857398
object.keys + reduce(FN, { proto: null }) 866,541 433294
object.keys + reduce(FN, { newProp: true }) 595,638 297859
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:07:11 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Sorting Map

name ops/sec samples
Sort using default 316,551 158276
Sort using first char 1,337,124 668787
Sort using localeCompare 1,241,180 620738
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:16:00 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 2,894 1449
{...smallObject} - Total keys: 2 34,125,546 17063575
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 1,025 513
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,622 3312
{ ...bigObject, ...anotherBigObject } 1,379 692
Object.assign({}, smallObject, anotherSmallObject) - creating new object 11,813,953 5906980
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 26,208,437 13104228
{ ...smallObject, ...anotherSmallObject } 19,107,375 9563880
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:16:52 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Stream.Readable

name ops/sec samples
streams.Readable reading 1e3 * "some data" 1,909 955
streams.web.Readable reading 1e3 * "some data" 1,564 783
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:22:43 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Stream.Writable

name ops/sec samples
streams.Writable writing 1e3 * "some data" 12,020 6028
streams.web.WritableStream writing 1e3 * "some data" 1,597 811
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:30:14 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

String concat

name ops/sec samples
Using + sign 85,087,874 42544311
Using backtick (`) 95,259,828 47658122
Using array.join 9,867,346 4933676
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:34:04 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 85,266,830 42639328
(short string) (true) String#slice and strict comparison 55,355,637 27687034
(long string) (true) String#endsWith 67,545,634 33773443
(long string) (true) String#slice and strict comparison 51,666,407 25835945
(short string) (false) String#endsWith 90,906,022 45453404
(short string) (false) String#slice and strict comparison 56,112,735 28061899
(long string) (false) String#endsWith 84,687,716 42343868
(long string) (false) String#slice and strict comparison 51,241,982 25640131
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:35:56 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

String searching

name ops/sec samples
Using includes 16,049,011 8024509
Using indexof 16,121,947 8061534
Using RegExp.test 13,207,605 6603925
Using RegExp.text with cached regex pattern 14,085,567 7042850
Using new RegExp.test 4,916,474 2458749
Using new RegExp.test with cached regex pattern 5,484,862 2742433
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:42:24 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 86,774,638 43407721
(short string) (true) String#slice and strict comparison 56,676,285 28338150
(long string) (true) String#startsWith 65,723,527 32884525
(long string) (true) String#slice and strict comparison 51,870,903 25937088
(short string) (false) String#startsWith 93,177,251 46593356
(short string) (false) String#slice and strict comparison 56,056,658 28054265
(long string) (false) String#startsWith 84,029,676 42014842
(long string) (false) String#slice and strict comparison 50,986,198 25496964
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:46:00 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Super vs This

name ops/sec samples
Using super 87,968,593 43984890
Using this 96,301,985 48151011
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:53:58 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1

Getting unix time

name ops/sec samples
new Date().getTime() 12,672,156 6336764
Date.now() 18,936,578 9468329
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Thu Sep 04 2025 19:56:57 GMT+0000 (Coordinated Universal Time)
  • Node: v23.11.1