Skip to content

Latest commit

 

History

History
809 lines (597 loc) · 39.3 KB

RESULTS-v23_1_0.md

File metadata and controls

809 lines (597 loc) · 39.3 KB

Adding property

name ops/sec samples
Directly in the object 89,867,993 44940659
Using dot notation 65,846,781 32926346
Using define property (writable) 4,737,823 2369075
Using define property initialized (writable) 7,038,125 3519082
Using define property (getter) 2,460,384 1230267
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 16:46:51 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Array.append (number)

type amount time elapsed
array.push 10 0.004ms
new Array(length) 10 0.002ms
array.push 100 0.071ms
new Array(length) 100 0.007ms
array.push 1,000 0.031ms
new Array(length) 1,000 0.017ms
array.push 10,000 0.45ms
new Array(length) 10,000 0.291ms
array.push 1,000,000 26.339ms
new Array(length) 1,000,000 6.44ms
array.push 100,000,000 1,806.725ms
new Array(length) 100,000,000 3,999.16ms

Array.append (string)

type amount time elapsed
array.push 10 0.005ms
new Array(length) 10 0.004ms
array.push 100 0.016ms
new Array(length) 100 0.012ms
array.push 1,000 0.037ms
new Array(length) 1,000 0.02ms
array.push 10,000 153.664ms
new Array(length) 10,000 0.032ms
array.push 1,000,000 16.394ms
new Array(length) 1,000,000 9.022ms
array.push 100,000,000 1,964.952ms
new Array(length) 100,000,000 4,658.797ms

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:29 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Blob

name ops/sec samples
new Blob (128) 4,811 2478
new Blob (1024) 609 305
text (128) 4,502 2256
text (1024) 576 289
arrayBuffer (128) 4,595 2301
arrayBuffer (1024) 576 290
slice (0, 64) 149,389 81730
slice (0, 512) 31,777 15892
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:06:41 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Comparison using instanceof

name ops/sec samples
[True conditional] Using instanceof only 444,653 222336
[True conditional] Using constructor name 352,333 176167
[True conditional] Check if property is valid then instanceof 354,334 177168
[False conditional] Using instanceof only 92,512,457 46680802
[False conditional] Using constructor name 93,535,788 46767919
[False conditional] Check if property is valid then instanceof 93,646,641 46823333
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:12:37 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,394 3198
crypto.verify('RSA-SHA256') 6,683 3342
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:18:00 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Date toISOString

name ops/sec samples
new Date().toISOString() 1,498,009 749086
fromUnixToISOString(new Date()) 2,312,765 1156384
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:23:33 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Date format MM/DD/YYYY

name ops/sec samples
Intl.DateTimeFormat().format(Date.now()) 20,100 10051
Intl.DateTimeFormat().format(new Date()) 19,587 9794
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(Date.now()) 19,243 9622
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(new Date()) 18,923 9462
Reusing Intl.DateTimeFormat() 575,482 287757
Date.toLocaleDateString() 1,166,263 583172
Date.toLocaleDateString(undefined, twoDigitsLocaleOptions) 24,668 12335
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:29:35 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Date String coersion

name ops/sec samples
Using String() 1,027,448 513860
Using brackets {} 1,049,601 524820
Using '' + 1,033,762 516882
Using date.toString() 1,149,814 575204
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:35:31 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Deleting properties

name ops/sec samples
Using delete property 3,450,499 1725404
Using delete property (proto: null) 16,675,412 8338556
Using delete property (cached proto: null) 3,422,439 1712143
Using undefined assignment 72,207,704 36103861
Using undefined assignment (proto: null) 17,952,841 8979339
Using undefined property (cached proto: null) 72,226,249 36119396
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:41:26 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Node.js Error

name ops/sec samples
Error 416,300 208151
NodeError 333,066 166536
NodeError Range 331,389 165695
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:46:42 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Function return

name ops/sec samples
Function returning null 1,903,323 951810
Function returning explicitly undefined 1,844,622 922429
Function returning implicitly undefined 1,902,010 951113
Function returning string 1,853,041 926522
Function returning integer 1,806,822 903436
Function returning float 1,880,574 940288
Function returning functions 1,827,934 913968
Function returning arrow functions 1,945,682 972842
Function returning empty object 1,983,249 991626
Function returning empty array 1,905,263 953770
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:52:39 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 84,540,089 42280369
using Array.includes (first item) 81,952,860 40993799
Using raw comparison 95,678,074 47839047
Using raw comparison (first item) 96,095,092 48047565
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:58:45 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 45,776,139 22890074
Using Object.getOwnPropertyNames() 41,272,674 20638613
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:03:40 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 121,957,548 60979027
Length = 10_000 - Array.at 89,761,038 44880528
Length = 1_000_000 - Array.at 86,528,860 43264454
Length = 100 - Array[length - 1] 85,961,671 43260445
Length = 10_000 - Array[length - 1] 86,903,256 43451649
Length = 1_000_000 - Array[length - 1] 86,800,964 43400491
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:09:10 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Math.floor vs ~

name ops/sec samples
Math.floor (small) 126,370,022 63547482
~ (small) 98,820,499 49422197
Math.floor (long) 94,821,648 47410840
~ (long) 95,601,739 47802739
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:15:26 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Object Creation

name ops/sec samples
Object.create(null) 42,581,046 21294519
Object.create({}) 2,098,922 1053956
Cached Empty.prototype 82,121,110 41062559
Empty.prototype 2,491,134 1246281
Empty class 1,710,118 855060
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:21:24 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Optional Chain (?) vs && operator

name ops/sec samples
Using optional chain (obj.field?.field2) (Valid) 126,550,321 63355075
Using optional chain (obj.field?.field2) (undefined) 92,189,126 46094577
Using and operator (obj.field && obj.field.field2) (Valid) 92,981,235 46562321
Using and operator (obj.field && obj.field.field2) (undefined) 90,923,454 45465509
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:26:49 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 124,940,448 62481897
Using parseInt(x, 10) - big number (10 len) 97,971,779 49028505
Using + - small number (2 len) 96,837,132 48418580
Using + - big number (10 len) 95,442,867 47722595
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:32:32 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Possible undefined Function

name ops/sec samples
Using if to check function existence 1,024,769 514480
Using ? operator to avoid rejection 1,079,757 539880
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:37:37 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Private Property

name ops/sec samples
Raw usage private field 132,098,219 66053717
Raw usage underscore usage 94,715,938 47357979
Manipulating private properties using # 93,429,324 46714698
Manipulating private properties using underscore(_) 93,418,421 46709318
Manipulating private properties using Symbol 93,936,585 46968307
Manipulating private properties using PrivateSymbol 32,018,161 16010715
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:44:04 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 7,868,359 3934251
Adding property in the object creation - small object 7,629,791 3815008
Adding property after the function creation - small class 272,414 136208
Adding property in the function creation - small class 282,905 141456
Adding property after the class creation - small class 277,672 138837
Adding property in the class creation - small class 279,712 139857
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:49:43 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Property Getter Access

name ops/sec samples
Getter (class) 124,849,906 62484920
Getter 48,786,123 24393073
Method 93,635,023 46817523
DefineProperty (getter) 94,323,938 47161995
DefineProperty (getter & enumerable=false) 50,238,185 25120137
DefineProperty (getter & configurable=false) 95,377,505 47688792
DefineProperty (getter & enumerable=false & configurable=false) 48,642,820 24323467
DefineProperty (writable) 97,320,980 48662916
DefineProperty (writable & enumerable=false) 95,861,205 47930629
DefineProperty (writable & enumerable=false & configurable=false) 89,150,586 44580938
DefineProperties (getter) 49,935,152 24967594
DefineProperties (getter & enumerable=false) 49,808,428 24910067
DefineProperties (getter & enumerable=false & configurable=false) 50,424,969 25220539
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:56:33 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Property Setter Access

name ops/sec samples
Setter (class) 123,594,638 61797965
Setter 11,730,811 5865409
Method 88,609,632 44305139
DefineProperty (setter) 99,056,180 49528172
DefineProperty (setter & enumerable=false) 11,685,495 5843602
DefineProperty (setter & configurable=false) 11,687,567 5843913
DefineProperty (setter & enumerable=false & configurable=false) 11,713,884 5856950
DefineProperty (writable) 98,858,364 49429258
DefineProperty (writable & enumerable=false) 97,670,986 48835531
DefineProperty (writable & enumerable=false & configurable=false) 98,508,406 49427336
DefineProperties (setter) 90,495,432 45248341
DefineProperties (setter & enumerable=false) 11,558,377 5779218
DefineProperties (setter & enumerable=false & configurable=false) 11,655,702 5827858
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:03:18 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

replace vs replaceAll comparison

name ops/sec samples
Using replace(//g) 3,282,388 1641196
Using replaceAll() 3,214,030 1607016
Using replaceAll(//g) 3,009,626 1504845
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:08:48 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Shallow Copy

name ops/sec samples
{ ...object } 23,517,728 11759788
{ ...object, proto: null } 2,570,917 1285713
{ ...object, newProp: true } 19,518,136 9759637
structuredClone 291,750 145876
JSON.parse + JSON.stringify 315,332 157675
loop + object.keys starting with {} 1,686,846 843440
loop + object.keys starting with { proto: null } 858,671 429468
loop + object.keys starting with { randomProp: true } 637,319 318660
object.keys + reduce(FN, {}) 1,762,309 881176
object.keys + reduce(FN, { proto: null }) 838,367 419193
object.keys + reduce(FN, { newProp: true }) 657,407 328704
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:14:58 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Sorting Map

name ops/sec samples
Sort using default 324,593 162297
Sort using first char 1,355,780 678308
Sort using localeCompare 1,271,630 635999
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:20:36 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 3,877 1940
{...smallObject} - Total keys: 2 56,771,373 28385690
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 1,083 542
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,703 3352
{ ...bigObject, ...anotherBigObject } 1,534 768
Object.assign({}, smallObject, anotherSmallObject) - creating new object 12,891,146 6447355
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 26,585,653 13292832
{ ...smallObject, ...anotherSmallObject } 20,369,758 10184993
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:27:05 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Stream.Readable

name ops/sec samples
streams.Readable reading 1e3 * "some data" 2,103 1052
streams.web.Readable reading 1e3 * "some data" 1,813 908
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:32:33 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Stream.Writable

name ops/sec samples
streams.Writable writing 1e3 * "some data" 13,450 6736
streams.web.WritableStream writing 1e3 * "some data" 1,635 818
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:38:14 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

String concat

name ops/sec samples
Using + sign 123,493,442 61746764
Using backtick (`) 98,315,609 49170083
Using array.join 9,973,219 4986779
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:43:54 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 114,292,970 57146522
(short string) (true) String#slice and strict comparison 56,242,803 28123346
(long string) (true) String#endsWith 66,772,793 33386399
(long string) (true) String#slice and strict comparison 50,955,372 25477911
(short string) (false) String#endsWith 92,801,498 46400752
(short string) (false) String#slice and strict comparison 56,760,152 28380086
(long string) (false) String#endsWith 85,061,519 42550923
(long string) (false) String#slice and strict comparison 51,314,636 25657346
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:49:37 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

String searching

name ops/sec samples
Using includes 129,384,492 64781546
Using indexof 16,146,598 8073682
Using RegExp.test 13,137,283 6568972
Using RegExp.text with cached regex pattern 14,306,616 7153313
Using new RegExp.test 4,585,027 2292640
Using new RegExp.test with cached regex pattern 5,195,425 2597886
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:56:01 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 115,289,375 57696226
(short string) (true) String#slice and strict comparison 56,530,690 28266733
(long string) (true) String#startsWith 65,941,221 32970642
(long string) (true) String#slice and strict comparison 50,282,649 25148062
(short string) (false) String#startsWith 92,242,100 46126021
(short string) (false) String#slice and strict comparison 55,603,586 27810173
(long string) (false) String#startsWith 84,215,723 42107877
(long string) (false) String#slice and strict comparison 50,218,159 25116309
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:02:14 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Super vs This

name ops/sec samples
Using super 115,257,337 57629432
Using this 96,632,227 48386567
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:11:13 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0

Getting unix time

name ops/sec samples
new Date().getTime() 12,868,024 6434016
Date.now() 20,085,855 10044133
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:16:22 GMT+0000 (Coordinated Universal Time)
  • Node: v23.1.0