1
1
# TypeScript-optimization
2
2
Tests and benchmarks different codes in TypeScript for different JavaScript versions (ES5 vs ES6 and above).
3
3
4
+ Benchmarks are done inside Atom (using script package) and Webstorm.
5
+
4
6
### Traditional ` for ` vs ` for-of ` vs ` for-in ` - Looping ovr Arrays
5
7
6
8
- ES6 and above: traditional ` for ` is ** faster** than ` for-of ` that is faster than ` for-in `
@@ -82,7 +84,7 @@ Defining `arr` as `const` or `let` doesn't affect the speed.
82
84
<summary >Benchmark-Result</summary >
83
85
84
86
const arr
85
-
87
+
86
88
ES2020:
87
89
88
90
for-traditional x 111,107 ops/sec ±0.38% (97 runs sampled)
@@ -98,14 +100,14 @@ Defining `arr` as `const` or `let` doesn't affect the speed.
98
100
Fastest is for-traditional,for-traditional-const,for-traditional-length-lookup
99
101
100
102
ES5:
101
-
103
+
102
104
for-traditional x 111,351 ops/sec ±0.17% (98 runs sampled)
103
105
for-traditional-const x 111,326 ops/sec ±0.15% (96 runs sampled)
104
106
for-traditional-lookup x 110,693 ops/sec ±0.42% (97 runs sampled)
105
107
Fastest is for-traditional
106
108
107
109
let arr:
108
-
110
+
109
111
ES2020:
110
112
111
113
for-traditional x 111,310 ops/sec ±0.23% (93 runs sampled)
@@ -114,7 +116,7 @@ Defining `arr` as `const` or `let` doesn't affect the speed.
114
116
Fastest is for-traditional-length-lookup,for-traditional,for-traditional-const
115
117
116
118
ES5:
117
-
119
+
118
120
for-traditional x 110,594 ops/sec ±0.53% (94 runs sampled)
119
121
for-traditional-const x 111,455 ops/sec ±0.14% (97 runs sampled)
120
122
for-traditional-lookup x 111,463 ops/sec ±0.15% (96 runs sampled)
0 commit comments