Skip to content

Commit 879aeec

Browse files
committed
Mention benchmark env
1 parent caabfb4 commit 879aeec

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# TypeScript-optimization
22
Tests and benchmarks different codes in TypeScript for different JavaScript versions (ES5 vs ES6 and above).
33

4+
Benchmarks are done inside Atom (using script package) and Webstorm.
5+
46
### Traditional `for` vs `for-of` vs `for-in`- Looping ovr Arrays
57

68
- 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.
8284
<summary>Benchmark-Result</summary>
8385

8486
const arr
85-
87+
8688
ES2020:
8789

8890
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.
98100
Fastest is for-traditional,for-traditional-const,for-traditional-length-lookup
99101

100102
ES5:
101-
103+
102104
for-traditional x 111,351 ops/sec ±0.17% (98 runs sampled)
103105
for-traditional-const x 111,326 ops/sec ±0.15% (96 runs sampled)
104106
for-traditional-lookup x 110,693 ops/sec ±0.42% (97 runs sampled)
105107
Fastest is for-traditional
106108

107109
let arr:
108-
110+
109111
ES2020:
110112

111113
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.
114116
Fastest is for-traditional-length-lookup,for-traditional,for-traditional-const
115117

116118
ES5:
117-
119+
118120
for-traditional x 110,594 ops/sec ±0.53% (94 runs sampled)
119121
for-traditional-const x 111,455 ops/sec ±0.14% (97 runs sampled)
120122
for-traditional-lookup x 111,463 ops/sec ±0.15% (96 runs sampled)

src/for-traditional-array.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Benchmark = require("benchmark")
22
let suite = new Benchmark.Suite()
33

4-
let arr: number[] = []
4+
const arr: number[] = []
55
for (let i = 0; i < 10000; ++i) arr.push(i)
66

77
// add tests

0 commit comments

Comments
 (0)