Skip to content

Instantly share code, notes, and snippets.

@hiroppy hiroppy/calc.js
Created May 19, 2019

Embed
What would you like to do?
Benchmarks: Compare es5 and es2015
const { readFile } = require('fs').promises;
(async () => {
const n = 3;
/**
1 middleware
5 middleware
10 middleware
15 middleware
20 middleware
30 middleware
50 middleware
100 middleware
*/
const middlewares = {};
// 3 times
for (let i = 1; i < n + 1; i++) {
const res = await readFile(`./res${i}`, 'utf-8');
const data = res
.split('\n')
.filter(Boolean)
.map((s) => s.trim());
for (let j = 1; j < data.length; j += 2) {
if (middlewares[data[j - 1]] === undefined) {
middlewares[data[j - 1]] = 0;
}
middlewares[data[j - 1]] += Number(data[j]);
}
}
Object.entries(middlewares).forEach(([key, value]) => {
console.log(key, 'average:', value / n);
});
})();

v12.2.0

master

1

  1 middleware
  9652.18

  5 middleware
  9355.48

  10 middleware
  9550.42

  15 middleware
  6078.65

  20 middleware
  8696.78

  30 middleware
  9076.64

  50 middleware
  6546.11

  100 middleware
  5747.77

2

  1 middleware
  9378.22

  5 middleware
  9254.36

  10 middleware
  9395.49

  15 middleware
  8978.95

  20 middleware
  8012.05

  30 middleware
  8047.60

  50 middleware
  8509.17

  100 middleware
  7631.24

3

  1 middleware
  8409.74

  5 middleware
  9034.98

  10 middleware
  8871.86

  15 middleware
  8975.99

  20 middleware
  8590.74

  30 middleware
  8728.41

  50 middleware
  8331.69

  100 middleware
  7734.54

es2015

1

  1 middleware
  8898.41

  5 middleware
  9410.14

  10 middleware
  8949.18

  15 middleware
  8929.16

  20 middleware
  8985.00

  30 middleware
  8175.30

  50 middleware
  8409.48

  100 middleware
  7204.69

2

  1 middleware
  8628.65

  5 middleware
  8621.92

  10 middleware
  8219.50

  15 middleware
  9111.55

  20 middleware
  8199.48

  30 middleware
  8071.27

  50 middleware
  7782.98

  100 middleware
  7577.18

3

  1 middleware
  8355.30

  5 middleware
  8110.18

  10 middleware
  8868.90

  15 middleware
  8905.01

  20 middleware
  8814.74

  30 middleware
  8122.96

  50 middleware
  7974.61

  100 middleware
  7859.60

v10.15.3

master

1

  1 middleware
  9215.30

  5 middleware
  7250.22

  10 middleware
  8945.82

  15 middleware
  8654.52

  20 middleware
  9153.04

  30 middleware
  8206.03

  50 middleware
  8075.00

  100 middleware
  7181.42

2


  1 middleware
  9814.70

  5 middleware
  6154.18

  10 middleware
  6023.72

  15 middleware
  7380.39

  20 middleware
  6723.84

  30 middleware
  4404.24

  50 middleware
  7528.97

  100 middleware
  6816.66

3


  1 middleware
  9490.98

  5 middleware
  9279.37

  10 middleware
  8830.61

  15 middleware
  9285.58

  20 middleware
  9293.66

  30 middleware
  8501.05

  50 middleware
  8214.72

  100 middleware
  6747.00

es2015

1

  1 middleware
  9321.77

  5 middleware
  5340.82

  10 middleware
  5348.22

  15 middleware
  8777.59

  20 middleware
  8422.49

  30 middleware
  8382.60

  50 middleware
  8075.40

  100 middleware
  5993.87

2

  1 middleware
  8672.85

  5 middleware
  8767.52

  10 middleware
  8246.11

  15 middleware
  8697.80

  20 middleware
  8693.13

  30 middleware
  8297.06

  50 middleware
  8475.92

  100 middleware
  6919.62

3

  1 middleware
  9161.62

  5 middleware
  9249.08

  10 middleware
  8722.49

  15 middleware
  8325.87

  20 middleware
  8798.12

  30 middleware
  8699.74

  50 middleware
  8013.51

  100 middleware
  6634.43

v8.16.0

master

1

  1 middleware
  4646.04

  5 middleware
  5243.97

  10 middleware
  7425.29

  15 middleware
  3642.89

  20 middleware
  6963.33

  30 middleware
  6656.05

  50 middleware
  5811.14

  100 middleware
  5314.85

2

  1 middleware
  8704.82

  5 middleware
  9071.57

  10 middleware
  9065.44

  15 middleware
  8655.19

  20 middleware
  8025.97

  30 middleware
  8278.85

  50 middleware
  7247.66

  100 middleware
  6381.96

3

  1 middleware
  9045.02

  5 middleware
  8287.76

  10 middleware
  8632.22

  15 middleware
  8167.67

  20 middleware
  8566.36

  30 middleware
  6213.47

  50 middleware
  6121.48

  100 middleware
  4004.15

es2015

1

  1 middleware
  8891.61

  5 middleware
  8305.69

  10 middleware
  8322.30

  15 middleware
  8169.57

  20 middleware
  8097.42

  30 middleware
  8112.78

  50 middleware
  7302.37

  100 middleware
  5907.54

2

  1 middleware
  8361.24

  5 middleware
  7926.33

  10 middleware
  7624.84

  15 middleware
  7928.33

  20 middleware
  6033.38

  30 middleware
  7608.90

  50 middleware
  7088.14

  100 middleware
  5602.67

3

  1 middleware
  7907.50

  5 middleware
  8642.01

  10 middleware
  7860.14

  15 middleware
  8342.29

  20 middleware
  7739.36

  30 middleware
  7096.14

  50 middleware
  6928.45

  100 middleware
  5487.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.