Skip to content

Latest commit

 

History

History
809 lines (597 loc) · 39.3 KB

RESULTS-v22_8_0.md

File metadata and controls

809 lines (597 loc) · 39.3 KB

Adding property

name ops/sec samples
Directly in the object 97,992,566 49062546
Using dot notation 68,204,549 34143479
Using define property (writable) 4,733,358 2366681
Using define property initialized (writable) 6,717,229 3359660
Using define property (getter) 2,400,392 1200259
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 16:45:53 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.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.006ms
array.push 1,000 0.049ms
new Array(length) 1,000 0.014ms
array.push 10,000 0.278ms
new Array(length) 10,000 0.165ms
array.push 1,000,000 27.671ms
new Array(length) 1,000,000 6.21ms
array.push 100,000,000 1,858.852ms
new Array(length) 100,000,000 3,945.527ms

Array.append (string)

type amount time elapsed
array.push 10 0.005ms
new Array(length) 10 0.003ms
array.push 100 0.016ms
new Array(length) 100 0.011ms
array.push 1,000 0.036ms
new Array(length) 1,000 0.019ms
array.push 10,000 160.289ms
new Array(length) 10,000 0.07ms
array.push 1,000,000 18.341ms
new Array(length) 1,000,000 6.902ms
array.push 100,000,000 2,043.329ms
new Array(length) 100,000,000 4,580.019ms

Array Creation

name ops/sec samples
new Array 328 167
Array.from 24 13
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 16:59:48 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Blob

name ops/sec samples
new Blob (128) 4,803 2419
new Blob (1024) 553 281
text (128) 4,127 2066
text (1024) 526 264
arrayBuffer (128) 4,036 2026
arrayBuffer (1024) 505 253
slice (0, 64) 187,024 93521
slice (0, 512) 15,241 14621
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:05:54 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Comparison using instanceof

name ops/sec samples
[True conditional] Using instanceof only 427,272 213672
[True conditional] Using constructor name 340,710 170371
[True conditional] Check if property is valid then instanceof 342,372 171200
[False conditional] Using instanceof only 96,175,779 48088628
[False conditional] Using constructor name 94,154,957 47109770
[False conditional] Check if property is valid then instanceof 96,972,172 48492544
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:11:49 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,810 3406
crypto.verify('RSA-SHA256') 6,778 3390
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:17:20 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Date toISOString

name ops/sec samples
new Date().toISOString() 1,435,653 717828
fromUnixToISOString(new Date()) 2,096,115 1048144
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:22:53 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Date format MM/DD/YYYY

name ops/sec samples
Intl.DateTimeFormat().format(Date.now()) 17,747 8874
Intl.DateTimeFormat().format(new Date()) 18,146 9074
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(Date.now()) 17,908 8955
Intl.DateTimeFormat(undefined, twoDigitsLocaleOptions).format(new Date()) 18,313 9158
Reusing Intl.DateTimeFormat() 512,660 256377
Date.toLocaleDateString() 949,399 474708
Date.toLocaleDateString(undefined, twoDigitsLocaleOptions) 22,859 11430
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:29:12 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Date String coersion

name ops/sec samples
Using String() 993,881 497007
Using brackets {} 1,031,300 515651
Using '' + 1,013,192 506642
Using date.toString() 1,137,623 568814
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:34:50 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Deleting properties

name ops/sec samples
Using delete property 4,027,628 2013816
Using delete property (proto: null) 16,077,434 8039562
Using delete property (cached proto: null) 3,953,469 1976736
Using undefined assignment 69,369,946 34684975
Using undefined assignment (proto: null) 17,906,217 8954499
Using undefined property (cached proto: null) 69,509,845 34754994
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:40:41 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Node.js Error

name ops/sec samples
Error 400,910 200462
NodeError 329,106 164554
NodeError Range 323,968 162253
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:45:42 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Function return

name ops/sec samples
Function returning null 1,668,057 834119
Function returning explicitly undefined 1,585,848 794420
Function returning implicitly undefined 1,624,108 812769
Function returning string 1,564,467 782235
Function returning integer 1,633,054 816586
Function returning float 1,625,360 812681
Function returning functions 1,629,460 814735
Function returning arrow functions 1,607,007 803504
Function returning empty object 1,635,541 817880
Function returning empty array 1,641,557 820792
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:51:51 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 84,644,044 42323732
using Array.includes (first item) 79,611,434 39805854
Using raw comparison 97,323,043 48661532
Using raw comparison (first item) 96,904,733 48701261
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 17:58:05 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 46,348,714 23176999
Using Object.getOwnPropertyNames() 40,565,096 20282552
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:03:21 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 123,688,129 61905711
Length = 10_000 - Array.at 96,615,151 48308520
Length = 1_000_000 - Array.at 97,434,391 48765481
Length = 100 - Array[length - 1] 97,367,682 48688874
Length = 10_000 - Array[length - 1] 97,175,810 48593623
Length = 1_000_000 - Array[length - 1] 95,312,261 47656140
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:09:33 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Math.floor vs ~

name ops/sec samples
Math.floor (small) 126,546,144 63495304
~ (small) 98,865,056 49432537
Math.floor (long) 92,490,367 46432697
~ (long) 96,376,265 48192947
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:15:06 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Object Creation

name ops/sec samples
Object.create(null) 39,474,943 19737483
Object.create({}) 2,058,225 1029253
Cached Empty.prototype 75,031,866 37518606
Empty.prototype 2,521,688 1272027
Empty class 1,557,295 778648
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:21:04 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Optional Chain (?) vs && operator

name ops/sec samples
Using optional chain (obj.field?.field2) (Valid) 141,297,371 70661631
Using optional chain (obj.field?.field2) (undefined) 98,710,485 49410422
Using and operator (obj.field && obj.field.field2) (Valid) 96,650,001 48384161
Using and operator (obj.field && obj.field.field2) (undefined) 97,941,359 48975110
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:26:08 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 128,591,382 64295833
Using parseInt(x, 10) - big number (10 len) 99,837,666 49918845
Using + - small number (2 len) 96,196,219 48098142
Using + - big number (10 len) 97,595,106 48801343
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:32:12 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Possible undefined Function

name ops/sec samples
Using if to check function existence 1,033,250 516654
Using ? operator to avoid rejection 1,082,209 541797
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:37:56 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Private Property

name ops/sec samples
Raw usage private field 130,251,125 65125950
Raw usage underscore usage 99,494,568 49765047
Manipulating private properties using # 97,168,454 48586272
Manipulating private properties using underscore(_) 96,894,982 48451353
Manipulating private properties using Symbol 97,295,613 48648357
Manipulating private properties using PrivateSymbol 35,093,819 17546917
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:43:21 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 7,247,486 3623769
Adding property in the object creation - small object 6,967,745 3483876
Adding property after the function creation - small class 254,292 127541
Adding property in the function creation - small class 269,824 134913
Adding property after the class creation - small class 256,082 128332
Adding property in the class creation - small class 259,991 131921
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:49:01 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Property Getter Access

name ops/sec samples
Getter (class) 140,685,356 70343570
Getter 51,059,989 25530003
Method 88,080,833 44046623
DefineProperty (getter) 95,207,617 47604496
DefineProperty (getter & enumerable=false) 51,172,614 25587940
DefineProperty (getter & configurable=false) 98,025,031 49024332
DefineProperty (getter & enumerable=false & configurable=false) 48,851,173 24431781
DefineProperty (writable) 97,019,074 48519030
DefineProperty (writable & enumerable=false) 98,039,071 49034556
DefineProperty (writable & enumerable=false & configurable=false) 95,951,257 47975638
DefineProperties (getter) 51,269,627 25634827
DefineProperties (getter & enumerable=false) 51,216,813 25629724
DefineProperties (getter & enumerable=false & configurable=false) 50,565,331 25288129
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 18:56:09 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Property Setter Access

name ops/sec samples
Setter (class) 127,260,416 63630252
Setter 11,239,316 5620256
Method 88,979,985 44490008
DefineProperty (setter) 92,293,112 46147589
DefineProperty (setter & enumerable=false) 11,529,685 5764847
DefineProperty (setter & configurable=false) 11,223,637 5611913
DefineProperty (setter & enumerable=false & configurable=false) 11,416,654 5708332
DefineProperty (writable) 92,119,995 46060226
DefineProperty (writable & enumerable=false) 92,639,377 46323121
DefineProperty (writable & enumerable=false & configurable=false) 93,933,338 46969568
DefineProperties (setter) 81,451,799 40726036
DefineProperties (setter & enumerable=false) 11,246,614 5623516
DefineProperties (setter & enumerable=false & configurable=false) 10,967,791 5485817
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:02:27 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

replace vs replaceAll comparison

name ops/sec samples
Using replace(//g) 3,383,623 1694374
Using replaceAll() 3,173,473 1586800
Using replaceAll(//g) 3,024,937 1512469
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:08:08 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Shallow Copy

name ops/sec samples
{ ...object } 23,866,895 11934569
{ ...object, proto: null } 2,497,880 1249013
{ ...object, newProp: true } 20,378,798 10190479
structuredClone 302,377 151189
JSON.parse + JSON.stringify 298,582 149299
loop + object.keys starting with {} 1,640,140 820160
loop + object.keys starting with { proto: null } 882,370 441222
loop + object.keys starting with { randomProp: true } 661,017 330518
object.keys + reduce(FN, {}) 1,723,515 861929
object.keys + reduce(FN, { proto: null }) 879,212 439607
object.keys + reduce(FN, { newProp: true }) 682,910 341537
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:14:33 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Sorting Map

name ops/sec samples
Sort using default 291,099 145550
Sort using first char 1,238,516 621330
Sort using localeCompare 1,175,230 587616
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:20:12 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 1,855 928
{...smallObject} - Total keys: 2 52,273,168 26157440
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 1,064 533
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,373 3187
{ ...bigObject, ...anotherBigObject } 1,138 570
Object.assign({}, smallObject, anotherSmallObject) - creating new object 12,931,762 6467517
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 28,350,400 14177346
{ ...smallObject, ...anotherSmallObject } 20,482,600 10242662
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:26:41 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Stream.Readable

name ops/sec samples
streams.Readable reading 1e3 * "some data" 2,052 1027
streams.web.Readable reading 1e3 * "some data" 1,792 897
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:31:52 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Stream.Writable

name ops/sec samples
streams.Writable writing 1e3 * "some data" 7,755 3878
streams.web.WritableStream writing 1e3 * "some data" 1,687 846
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:37:32 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

String concat

name ops/sec samples
Using + sign 136,898,236 68449174
Using backtick (`) 98,989,988 49498210
Using array.join 9,972,235 4986656
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:43:12 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 120,955,422 60477730
(short string) (true) String#slice and strict comparison 56,906,337 28453256
(long string) (true) String#endsWith 64,896,681 32458096
(long string) (true) String#slice and strict comparison 51,932,071 25969623
(short string) (false) String#endsWith 95,422,057 47711038
(short string) (false) String#slice and strict comparison 56,876,948 28440136
(long string) (false) String#endsWith 87,536,997 43826802
(long string) (false) String#slice and strict comparison 51,255,867 25640503
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:49:14 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

String searching

name ops/sec samples
Using includes 121,691,515 60885802
Using indexof 15,186,408 7598606
Using RegExp.test 12,667,582 6333794
Using RegExp.text with cached regex pattern 13,374,371 6687266
Using new RegExp.test 4,463,791 2232067
Using new RegExp.test with cached regex pattern 5,049,096 2524550
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 19:55:16 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 119,744,275 59872181
(short string) (true) String#slice and strict comparison 53,816,588 26914114
(long string) (true) String#startsWith 65,229,184 32615093
(long string) (true) String#slice and strict comparison 50,726,275 25363142
(short string) (false) String#startsWith 88,038,793 44019492
(short string) (false) String#slice and strict comparison 54,717,123 27369164
(long string) (false) String#startsWith 87,033,198 43517312
(long string) (false) String#slice and strict comparison 50,762,513 25383378
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:01:51 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Super vs This

name ops/sec samples
Using super 113,854,030 56929420
Using this 99,202,530 49676968
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:10:31 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0

Getting unix time

name ops/sec samples
new Date().getTime() 9,935,974 4969025
Date.now() 18,975,645 9487829
Environment
  • Machine: linux x64 | 4 vCPUs | 7.6GB Mem
  • Run: Tue Oct 29 2024 20:16:02 GMT+0000 (Coordinated Universal Time)
  • Node: v22.8.0