Skip to content

Latest commit

 

History

History
634 lines (464 loc) · 32.5 KB

RESULTS-v21_7_2.md

File metadata and controls

634 lines (464 loc) · 32.5 KB

Adding property

name ops/sec samples
Directly in the object 15,099,625 7549813
Using dot notation 15,103,744 7551873
Using define property (writable) 3,521,863 1760932
Using define property initialized (writable) 4,403,450 2201726
Using define property (getter) 2,326,675 1163338
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Mon May 13 2024 18:30:21 GMT+0000 (Coordinated Universal Time)

Array.append (number)

type amount time elapsed
array.push 10 0.004ms
new Array(length) 10 0.002ms
array.push 100 0.021ms
new Array(length) 100 0.011ms
array.push 1,000 0.032ms
new Array(length) 1,000 0.015ms
array.push 10,000 0.271ms
new Array(length) 10,000 0.147ms
array.push 1,000,000 32.01ms
new Array(length) 1,000,000 8.102ms
array.push 100,000,000 1,964.034ms
new Array(length) 100,000,000 4,157.641ms

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.039ms
new Array(length) 1,000 0.021ms
array.push 10,000 0.307ms
new Array(length) 10,000 0.2ms
array.push 1,000,000 19.533ms
new Array(length) 1,000,000 7.116ms
array.push 100,000,000 2,105.143ms
new Array(length) 100,000,000 4,789.418ms

Array Creation

name ops/sec samples
new Array 233 118
Array.from 23 12
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Mon May 13 2024 18:52:16 GMT+0000 (Coordinated Universal Time)

Comparison using instanceof

name ops/sec samples
[True conditional] Using instanceof only 315,017 157509
[True conditional] Using constructor name 325,934 162968
[True conditional] Check if property is valid then instanceof 329,050 164526
[False conditional] Using instanceof only 14,346,824 7173413
[False conditional] Using constructor name 14,291,786 7146078
[False conditional] Check if property is valid then instanceof 14,253,977 7126989
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Mon May 13 2024 15:49:41 GMT+0000 (Coordinated Universal Time)

Crypto Verify

name ops/sec samples
crypto.createVerify('RSA-SHA256') 6,646 3324
crypto.verify('RSA-SHA256') 7,269 3635
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Mon May 13 2024 15:55:04 GMT+0000 (Coordinated Universal Time)

Date String coersion

name ops/sec samples
Using String() 1,061,758 530880
Using brackets {} 1,068,015 534008
Using '' + 1,086,140 543071
Using date.toString() 1,185,525 592763
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Mon May 13 2024 16:09:47 GMT+0000 (Coordinated Universal Time)

Deleting properties

name ops/sec samples
Using delete property 2,983,939 1491970
Using delete property (proto: null) 8,701,295 4350648
Using delete property (cached proto: null) 2,909,106 1454554
Using undefined assignment 15,232,898 7616450
Using undefined assignment (proto: null) 9,325,026 4662514
Using undefined property (cached proto: null) 15,252,661 7626331
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:24:01 GMT+0000 (Coordinated Universal Time)

Node.js Error

name ops/sec samples
Error 317,716 158859
NodeError 312,960 156481
NodeError Range 313,862 156932
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:29:15 GMT+0000 (Coordinated Universal Time)

Function return

name ops/sec samples
Function returning null 1,642,615 821308
Function returning explicitly undefined 1,632,500 816251
Function returning implicitly undefined 1,667,447 833724
Function returning string 1,610,377 805189
Function returning integer 1,659,802 829902
Function returning float 1,645,506 822754
Function returning functions 1,616,727 808364
Function returning arrow functions 1,609,904 804953
Function returning empty object 1,628,695 814348
Function returning empty array 1,630,609 815305
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:35:27 GMT+0000 (Coordinated Universal Time)

Array.includes vs raw comparison

name ops/sec samples
using Array.includes 15,240,298 7620150
using Array.includes (first item) 15,301,004 7650503
Using raw comparison 15,258,321 7629161
Using raw comparison (first item) 15,304,793 7652397
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:44:32 GMT+0000 (Coordinated Universal Time)

Object.keys vs Object.getOwnPropertyNames comparison

name ops/sec samples
Using Object.keys() 13,096,780 6548391
Using Object.getOwnPropertyNames() 13,253,811 6626906
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:50:06 GMT+0000 (Coordinated Universal Time)

Get the last item of an Array

name ops/sec samples
Length = 100 - Array.at 15,046,076 7523039
Length = 10_000 - Array.at 15,006,393 7503197
Length = 1_000_000 - Array.at 15,062,881 7531441
Length = 100 - Array[length - 1] 15,132,091 7566046
Length = 10_000 - Array[length - 1] 15,085,789 7542895
Length = 1_000_000 - Array[length - 1] 15,138,261 7569131
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 21:59:02 GMT+0000 (Coordinated Universal Time)

Object Creation

name ops/sec samples
Object.create(null) 12,693,359 6346680
Object.create({}) 2,078,476 1042807
Cached Empty.prototype 15,171,541 7585771
Empty.prototype 1,963,651 982858
Empty class 1,350,605 675303
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:07:01 GMT+0000 (Coordinated Universal Time)

Optional Chain (?) vs && operator

name ops/sec samples
Using optional chain (obj.field?.field2) (Valid) 15,281,852 7640927
Using optional chain (obj.field?.field2) (undefined) 15,346,195 7673098
Using and operator (obj.field && obj.field.field2) (Valid) 15,360,543 7680272
Using and operator (obj.field && obj.field.field2) (undefined) 15,367,615 7683808
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:15:33 GMT+0000 (Coordinated Universal Time)

Parsing Integer

name ops/sec samples
Using parseInt(x, 10) - small number (2 len) 15,320,789 7660396
Using parseInt(x, 10) - big number (10 len) 15,388,163 7694082
Using + - small number (2 len) 15,340,846 7670424
Using + - big number (10 len) 15,358,939 7679470
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:22:57 GMT+0000 (Coordinated Universal Time)

Possible undefined Function

name ops/sec samples
Using if to check function existence 1,089,146 544574
Using ? operator to avoid rejection 1,101,146 551034
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:28:37 GMT+0000 (Coordinated Universal Time)

Private Property

name ops/sec samples
Raw usage private field 15,060,130 7530066
Raw usage underscore usage 15,090,203 7545102
Manipulating private properties using # 15,131,045 7565523
Manipulating private properties using underscore(_) 15,157,256 7578629
Manipulating private properties using Symbol 15,127,204 7563603
Manipulating private properties using PrivateSymbol 12,160,012 6080007
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:36:14 GMT+0000 (Coordinated Universal Time)

Property access after shape transition

name ops/sec samples
Adding property after object creation - small object 3,719,202 1859602
Adding property in the object creation - small object 3,724,626 1862314
Adding property after the function creation - small class 264,046 132024
Adding property in the function creation - small class 272,252 136127
Adding property after the class creation - small class 262,285 131143
Adding property in the class creation - small class 263,326 132700
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:43:23 GMT+0000 (Coordinated Universal Time)

Property Getter Access

name ops/sec samples
Getter (class) 15,283,531 7641766
Getter 13,380,021 6690011
Method 15,204,229 7602115
DefineProperty (getter) 15,372,668 7686335
DefineProperty (getter & enumerable=false) 13,279,174 6639588
DefineProperty (getter & configurable=false) 15,337,251 7668627
DefineProperty (getter & enumerable=false & configurable=false) 13,401,263 6700632
DefineProperty (writable) 15,357,440 7678749
DefineProperty (writable & enumerable=false) 15,355,988 7677995
DefineProperty (writable & enumerable=false & configurable=false) 15,211,084 7605543
DefineProperties (getter) 13,366,308 6683155
DefineProperties (getter & enumerable=false) 13,394,230 6697116
DefineProperties (getter & enumerable=false & configurable=false) 13,356,950 6678476
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 22:59:36 GMT+0000 (Coordinated Universal Time)

Property Setter Access

name ops/sec samples
Setter (class) 15,135,859 7567930
Setter 6,737,927 3368964
Method 15,130,536 7565269
DefineProperty (setter) 15,117,902 7558952
DefineProperty (setter & enumerable=false) 6,673,943 3336972
DefineProperty (setter & configurable=false) 6,611,723 3305862
DefineProperty (setter & enumerable=false & configurable=false) 6,647,834 3323918
DefineProperty (writable) 15,184,278 7592140
DefineProperty (writable & enumerable=false) 15,217,736 7608869
DefineProperty (writable & enumerable=false & configurable=false) 15,222,493 7611247
DefineProperties (setter) 15,018,574 7509288
DefineProperties (setter & enumerable=false) 6,741,154 3370578
DefineProperties (setter & enumerable=false & configurable=false) 6,788,281 3394141
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 23:13:20 GMT+0000 (Coordinated Universal Time)

Shallow Copy

name ops/sec samples
{ ...object } 10,415,058 5207530
{ ...object, proto: null } 2,268,126 1134064
{ ...object, newProp: true } 10,262,814 5131408
structuredClone 303,085 151543
JSON.parse + JSON.stringify 244,205 122103
loop + object.keys starting with {} 1,450,006 725004
loop + object.keys starting with { proto: null } 802,896 401501
loop + object.keys starting with { randomProp: true } 652,890 326446
object.keys + reduce(FN, {}) 1,476,269 738135
object.keys + reduce(FN, { proto: null }) 807,574 403788
object.keys + reduce(FN, { newProp: true }) 667,542 333772
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 23:27:27 GMT+0000 (Coordinated Universal Time)

Sorting Map

name ops/sec samples
Sort using default 335,575 167788
Sort using first char 1,318,298 659150
Sort using localeCompare 1,233,585 616793
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 23:35:56 GMT+0000 (Coordinated Universal Time)

Object.assign VS spread operator

name ops/sec samples
{...bigObject} - Total keys: 1000 2,253 1127
{...smallObject} - Total keys: 2 11,961,965 5980983
Object.assign({}, bigObject, anotherBigObject) - Total keys: 1000 - creating new object 2,478 1240
Object.assign(bigObject, anotherBigObject) - mutating bigObject 6,874 3438
{ ...bigObject, ...anotherBigObject } 1,401 701
Object.assign({}, smallObject, anotherSmallObject) - creating new object 6,953,303 3476652
Object.assign(smallObject, anotherSmallObject) - mutating smallObject 10,322,749 5161375
{ ...smallObject, ...anotherSmallObject } 8,776,918 4388460
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Thu May 09 2024 23:42:36 GMT+0000 (Coordinated Universal Time)

String concat

name ops/sec samples
Using + sign 15,129,699 7564850
Using backtick (`) 15,377,059 7688530
Using array.join 6,278,288 3139145
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:01:38 GMT+0000 (Coordinated Universal Time)

endsWith comparison

name ops/sec samples
(short string) (true) String#endsWith 14,437,305 7218653
(short string) (true) String#slice and strict comparison 15,358,476 7679239
(long string) (true) String#endsWith 13,787,381 6893691
(long string) (true) String#slice and strict comparison 15,271,773 7635887
(short string) (false) String#endsWith 15,095,218 7547610
(short string) (false) String#slice and strict comparison 15,324,887 7662444
(long string) (false) String#endsWith 14,845,467 7422734
(long string) (false) String#slice and strict comparison 15,392,559 7696280
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:13:04 GMT+0000 (Coordinated Universal Time)

String searching

name ops/sec samples
Using includes 15,207,942 7603972
Using indexof 15,299,501 7649751
Using RegExp.test 8,219,425 4109713
Using RegExp.text with cached regex pattern 8,276,553 4138277
Using new RegExp.test 3,625,998 1813000
Using new RegExp.test with cached regex pattern 3,893,803 1946902
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:22:44 GMT+0000 (Coordinated Universal Time)

startsWith comparison

name ops/sec samples
(short string) (true) String#startsWith 14,542,062 7271032
(short string) (true) String#slice and strict comparison 15,144,849 7572425
(long string) (true) String#startsWith 13,477,614 6738808
(long string) (true) String#slice and strict comparison 15,170,182 7585092
(short string) (false) String#startsWith 14,812,468 7406235
(short string) (false) String#slice and strict comparison 15,252,213 7626108
(long string) (false) String#startsWith 14,598,871 7299436
(long string) (false) String#slice and strict comparison 15,215,360 7607681
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:33:12 GMT+0000 (Coordinated Universal Time)

Super vs This

name ops/sec samples
Using super 14,980,630 7490316
Using this 15,102,881 7551441
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:40:47 GMT+0000 (Coordinated Universal Time)

Getting unix time

name ops/sec samples
new Date().getTime() 6,799,799 3399900
Date.now() 8,936,520 4468261
Environment
  • Machine: linux x64 | 4 vCPUs | 15.2GB Mem
  • Run: Fri May 10 2024 00:46:27 GMT+0000 (Coordinated Universal Time)