Skip to content

Latest commit

 

History

History
809 lines (597 loc) · 39.3 KB

RESULTS-v23_0_0.md

File metadata and controls

809 lines (597 loc) · 39.3 KB

Adding property

name ops/sec samples
Directly in the object 90,874,298 45877240
Using dot notation 65,305,237 33162498
Using define property (writable) 4,206,061 2112781
Using define property initialized (writable) 3,041,001 1520502
Using define property (getter) 2,201,846 1102405
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 16:46:23 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Array.append (number)

type amount time elapsed
array.push 10 0.004ms
new Array(length) 10 0.002ms
array.push 100 0.072ms
new Array(length) 100 0.009ms
array.push 1,000 0.03ms
new Array(length) 1,000 0.017ms
array.push 10,000 0.308ms
new Array(length) 10,000 0.181ms
array.push 1,000,000 29.825ms
new Array(length) 1,000,000 6.805ms
array.push 100,000,000 1,832.759ms
new Array(length) 100,000,000 3,990ms

Array.append (string)

type amount time elapsed
array.push 10 0.005ms
new Array(length) 10 0.003ms
array.push 100 0.017ms
new Array(length) 100 0.012ms
array.push 1,000 0.037ms
new Array(length) 1,000 0.019ms
array.push 10,000 177.637ms
new Array(length) 10,000 0.032ms
array.push 1,000,000 16.2ms
new Array(length) 1,000,000 7.419ms
array.push 100,000,000 1,955.219ms
new Array(length) 100,000,000 4,663.106ms

Array Creation

name ops/sec samples
new Array 333 168
Array.from 23 12
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:00:07 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Blob

name ops/sec samples
new Blob (128) 4,927 2464
new Blob (1024) 629 317
text (128) 4,320 2161
text (1024) 550 276
arrayBuffer (128) 4,387 2194
arrayBuffer (1024) 549 275
slice (0, 64) 150,159 86444
slice (0, 512) 32,651 16326
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:06:18 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Comparison using instanceof

name ops/sec samples
[True conditional] Using instanceof only 453,616 226809
[True conditional] Using constructor name 351,155 175578
[True conditional] Check if property is valid then instanceof 351,689 175863
[False conditional] Using instanceof only 92,178,120 46093674
[False conditional] Using constructor name 92,983,061 46494041
[False conditional] Check if property is valid then instanceof 87,744,020 43872332
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:12:10 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,640 3321
crypto.verify('RSA-SHA256') 6,799 3400
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:17:39 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Date toISOString

name ops/sec samples
new Date().toISOString() 1,232,525 616307
fromUnixToISOString(new Date()) 2,342,481 1171241
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:23:13 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Date format MM/DD/YYYY

name ops/sec samples
Intl.DateTimeFormat().format(Date.now()) 19,985 9994
Intl.DateTimeFormat().format(new Date()) 19,583 9792
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(Date.now()) 18,996 9499
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(new Date()) 19,182 9592
Reusing Intl.DateTimeFormat() 597,926 298989
Date.toLocaleDateString() 1,078,626 539315
Date.toLocaleDateString(undefined, twoDigitsLocaleOptions) 24,719 12361
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:29:56 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Date String coersion

name ops/sec samples
Using String() 877,003 438503
Using brackets {} 926,055 463029
Using '' + 928,161 464081
Using date.toString() 1,008,634 504348
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:35:11 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Deleting properties

name ops/sec samples
Using delete property 3,938,479 1969433
Using delete property (proto: null) 17,171,430 8586188
Using delete property (cached proto: null) 3,921,535 1960814
Using undefined assignment 67,835,268 33917652
Using undefined assignment (proto: null) 18,247,282 9125552
Using undefined property (cached proto: null) 70,846,584 35428118
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:41:04 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Node.js Error

name ops/sec samples
Error 416,384 208193
NodeError 338,615 169308
NodeError Range 335,554 167815
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:46:02 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Function return

name ops/sec samples
Function returning null 1,808,205 904104
Function returning explicitly undefined 1,705,170 853094
Function returning implicitly undefined 1,790,056 895029
Function returning string 1,735,811 867941
Function returning integer 1,697,248 848625
Function returning float 1,777,149 888741
Function returning functions 1,773,976 888840
Function returning arrow functions 1,813,573 906793
Function returning empty object 1,835,470 917736
Function returning empty array 1,798,577 899810
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:53:07 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 83,398,079 41722728
using Array.includes (first item) 77,172,358 38586183
Using raw comparison 95,234,838 47623287
Using raw comparison (first item) 89,280,280 44640874
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:58:25 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 46,887,241 23460428
Using Object.getOwnPropertyNames() 40,261,815 20130912
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:04:00 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 121,593,112 60796640
Length = 10_000 - Array.at 96,470,985 48235503
Length = 1_000_000 - Array.at 92,711,686 46356883
Length = 100 - Array[length - 1] 93,153,977 46579116
Length = 10_000 - Array[length - 1] 93,809,778 46910354
Length = 1_000_000 - Array[length - 1] 93,768,710 46884365
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:09:54 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Math.floor vs ~

name ops/sec samples
Math.floor (small) 125,617,625 62877824
~ (small) 97,864,988 48943603
Math.floor (long) 95,753,477 47876773
~ (long) 94,855,938 47429719
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:14:46 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Object Creation

name ops/sec samples
Object.create(null) 43,123,113 21564921
Object.create({}) 2,149,608 1083924
Cached Empty.prototype 105,203,616 52614133
Empty.prototype 2,488,191 1256493
Empty class 1,689,430 844716
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:20:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Optional Chain (?) vs && operator

name ops/sec samples
Using optional chain (obj.field?.field2) (Valid) 125,518,857 62760043
Using optional chain (obj.field?.field2) (undefined) 86,541,559 43270799
Using and operator (obj.field && obj.field.field2) (Valid) 95,468,231 47734129
Using and operator (obj.field && obj.field.field2) (undefined) 95,303,051 47651560
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:26:28 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 125,758,684 62879399
Using parseInt(x, 10) - big number (10 len) 97,804,665 48967101
Using + - small number (2 len) 89,337,397 44668713
Using + - big number (10 len) 95,386,166 47693095
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:31:52 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Possible undefined Function

name ops/sec samples
Using if to check function existence 898,874 449445
Using ? operator to avoid rejection 1,190,542 605792
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:38:15 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Private Property

name ops/sec samples
Raw usage private field 132,243,709 66121894
Raw usage underscore usage 92,082,496 46041277
Manipulating private properties using # 91,088,651 45544334
Manipulating private properties using underscore(_) 93,350,397 46675808
Manipulating private properties using Symbol 91,683,603 45842067
Manipulating private properties using PrivateSymbol 35,563,191 17782928
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:43:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 7,926,835 3963449
Adding property in the object creation - small object 7,844,856 3924088
Adding property after the function creation - small class 269,550 135960
Adding property in the function creation - small class 289,233 144973
Adding property after the class creation - small class 278,058 141019
Adding property in the class creation - small class 274,817 137438
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:49:22 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Property Getter Access

name ops/sec samples
Getter (class) 125,073,973 62626994
Getter 48,558,898 24333570
Method 94,672,357 47337388
DefineProperty (getter) 96,331,290 48172417
DefineProperty (getter & enumerable=false) 49,985,731 25009625
DefineProperty (getter & configurable=false) 96,789,651 48395704
DefineProperty (getter & enumerable=false & configurable=false) 48,075,803 24037910
DefineProperty (writable) 84,465,846 42237184
DefineProperty (writable & enumerable=false) 96,754,190 48377209
DefineProperty (writable & enumerable=false & configurable=false) 96,148,880 48084704
DefineProperties (getter) 47,491,918 23748004
DefineProperties (getter & enumerable=false) 48,997,124 24498568
DefineProperties (getter & enumerable=false & configurable=false) 48,412,290 24206803
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:55:43 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Property Setter Access

name ops/sec samples
Setter (class) 125,302,435 62652580
Setter 11,285,616 5642812
Method 91,036,769 45519210
DefineProperty (setter) 97,779,388 48889712
DefineProperty (setter & enumerable=false) 11,022,230 5511120
DefineProperty (setter & configurable=false) 11,106,711 5553441
DefineProperty (setter & enumerable=false & configurable=false) 11,174,803 5588055
DefineProperty (writable) 97,842,783 48922085
DefineProperty (writable & enumerable=false) 98,812,004 49413692
DefineProperty (writable & enumerable=false & configurable=false) 97,125,839 48562955
DefineProperties (setter) 90,807,382 45406504
DefineProperties (setter & enumerable=false) 10,991,730 5495908
DefineProperties (setter & enumerable=false & configurable=false) 10,408,978 5204494
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:02:53 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

replace vs replaceAll comparison

name ops/sec samples
Using replace(//g) 3,323,874 1664390
Using replaceAll() 3,158,916 1581904
Using replaceAll(//g) 2,950,048 1475152
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:08:28 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Shallow Copy

name ops/sec samples
{ ...object } 23,386,788 11710101
{ ...object, proto: null } 2,577,319 1288735
{ ...object, newProp: true } 19,367,467 9683937
structuredClone 318,706 159354
JSON.parse + JSON.stringify 304,932 152480
loop + object.keys starting with {} 1,721,466 860734
loop + object.keys starting with { proto: null } 892,789 446467
loop + object.keys starting with { randomProp: true } 651,576 325833
object.keys + reduce(FN, {}) 1,790,989 895495
object.keys + reduce(FN, { proto: null }) 912,207 456464
object.keys + reduce(FN, { newProp: true }) 666,001 333002
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:15:26 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Sorting Map

name ops/sec samples
Sort using default 329,729 164866
Sort using first char 1,345,028 672591
Sort using localeCompare 1,240,335 620182
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:20:56 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 4,102 2053
{...smallObject} - Total keys: 2 55,113,881 27583585
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 1,088 545
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,756 3379
{ ...bigObject, ...anotherBigObject } 1,535 768
Object.assign({}, smallObject, anotherSmallObject) - creating new object 13,084,408 6542209
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 26,543,494 13271784
{ ...smallObject, ...anotherSmallObject } 20,120,899 10060785
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:26:19 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Stream.Readable

name ops/sec samples
streams.Readable reading 1e3 * "some data" 2,092 1047
streams.web.Readable reading 1e3 * "some data" 1,827 914
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:32:13 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Stream.Writable

name ops/sec samples
streams.Writable writing 1e3 * "some data" 12,792 6397
streams.web.WritableStream writing 1e3 * "some data" 1,662 835
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:37:53 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

String concat

name ops/sec samples
Using + sign 123,148,505 61579748
Using backtick (`) 94,812,895 48040260
Using array.join 9,831,993 4916182
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:43:33 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 114,778,906 57392271
(short string) (true) String#slice and strict comparison 55,892,450 27949291
(long string) (true) String#endsWith 66,924,190 33462114
(long string) (true) String#slice and strict comparison 51,123,953 25565907
(short string) (false) String#endsWith 91,773,522 45886780
(short string) (false) String#slice and strict comparison 56,076,158 28053756
(long string) (false) String#endsWith 85,147,612 42580695
(long string) (false) String#slice and strict comparison 51,588,440 25797114
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:49:59 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

String searching

name ops/sec samples
Using includes 126,983,452 64545135
Using indexof 17,533,536 8774409
Using RegExp.test 13,846,031 6923799
Using RegExp.text with cached regex pattern 15,329,932 7664968
Using new RegExp.test 4,967,958 2484273
Using new RegExp.test with cached regex pattern 5,512,829 2756416
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:55:38 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 115,249,326 57690854
(short string) (true) String#slice and strict comparison 55,927,016 27964966
(long string) (true) String#startsWith 63,453,631 31732077
(long string) (true) String#slice and strict comparison 50,743,497 25371765
(short string) (false) String#startsWith 93,079,242 46539858
(short string) (false) String#slice and strict comparison 56,032,855 28018818
(long string) (false) String#startsWith 83,126,691 41569899
(long string) (false) String#slice and strict comparison 50,867,582 25434238
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:01:29 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Super vs This

name ops/sec samples
Using super 107,085,522 53543434
Using this 94,291,683 47147376
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:10:52 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0

Getting unix time

name ops/sec samples
new Date().getTime() 13,244,575 6623331
Date.now() 20,117,909 10060948
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:16:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.0.0