Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
doc: now is more reasy to add a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed May 22, 2017
1 parent 6d909c8 commit 4f1c50e
Show file tree
Hide file tree
Showing 41 changed files with 255 additions and 863 deletions.
21 changes: 1 addition & 20 deletions Makefile.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ bench: lint
tail -n 23 out.txt > bench.txt
rm out.txt
npm run benchmark2 > bench2.txt
node --prof prof-foo.js > /dev/null <--Here you need to add your prof-foo.js
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-foo.txt <--Here you name the file like tick-foo.txt
rm *.log && rm out.txt
node --prof prof-bar.js > /dev/null <--Here you need to add your prof-bar.js
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-bar.txt <--Here you name the file like tick-bar.txt
rm *.log && rm out.txt && touch README.md && rm README.md
touch README.md && rm README.md
echo '## Benchmark' >> README.md
echo ' ' >> README.md
echo '```' >> README.md
Expand All @@ -23,18 +16,6 @@ bench: lint
tail -n 4 bench2.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo '## Profile summary' >> README.md
echo ' ' >> README.md
echo 'Tick-foo' >> README.md <--Here you need to change
echo '```' >> README.md
cat tick-foo.txt >> README.md <--Here you need to change
echo '```' >> README.md
echo ' ' >> README.md
echo 'Tick-bar' >> README.md <--Here you need to change
echo '```' >> README.md
cat tick-bar.txt >> README.md <--Here you need to change
echo '```' >> README.md
echo ' ' >> README.md
rm *.txt
lint: node_modules
npm run lint
Expand Down
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,17 @@
- [reduce and reduce by hand](reduce-reduce_by_hand/#readme)
- [Function expression and function statement](function_expression-function_statement/#readme)
- [WeakMap and Symbol](weakmap-symbol/#readme)
- [object assign and util extend](object_assign-util_extend/#readme)

### How to push a test case

- Create a new directory using the rule `foo-bar` or `function_foo-function_bar`
- Create benchmark.js and benchmark2.js files and add your bench code (look the other tests to get help).
- Create a prof-foo.js and prof-bar.js and replicate the bench code from step 2.
using as comparision, the same function call, like this:

```
exports.compare = {
'arrow1': function () {
foo(1);
},
'arrow2': function () {
foo(1);
}
};
```

- Copy Makefile.example from the root directory, rename it to Makefile and change for your needs.
- Copy Makefile.example from the root directory, rename it to Makefile.
- Type `make` inside your test case directory.
- Add the test case on Makefile located on project root directory.
- To run all the tests type `make` from project root directory.

## Benchmarks

Benchmarks are notoriously a lot like statistics so take this with a grain of salt.
Results from a simplified, non-scientific benchmark performed on a
Lenovo T440 Linux 4.8.4-1-ARCH x86_64. Your results may vary.
21 changes: 1 addition & 20 deletions class-classless/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ bench: lint
tail -n 23 out.txt > bench.txt
rm out.txt
npm run benchmark2 > bench2.txt
node --prof prof-class.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-class.txt
rm *.log && rm out.txt
node --prof prof-classless.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-classless.txt
rm *.log && rm out.txt && touch README.md && rm README.md
touch README.md && rm README.md
echo '## Benchmark' >> README.md
echo ' ' >> README.md
echo '```' >> README.md
Expand All @@ -23,18 +16,6 @@ bench: lint
tail -n 4 bench2.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo '## Profile summary' >> README.md
echo ' ' >> README.md
echo 'Tick-class' >> README.md
echo '```' >> README.md
cat tick-class.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo 'Tick-classless' >> README.md
echo '```' >> README.md
cat tick-classless.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
rm *.txt
lint: node_modules
npm run lint
Expand Down
54 changes: 16 additions & 38 deletions class-classless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,35 @@
```
class
Raw:
> 146117.8821178821
> 144694.3056943057
> 148963.03696303695
> 147041.95804195805
Average (mean) 146704.2957042957
> 158595.4045954046
> 154682.3176823177
> 156602.3976023976
> 157400.5994005994
Average (mean) 156820.17982017982
classless
Raw:
> 11836.163836163836
> 11582.417582417582
> 11775.224775224775
> 11757.242757242757
Average (mean) 11737.762237762236
> 11382.617382617382
> 11383.616383616383
> 11547.452547452547
> 11587.412587412588
Average (mean) 11475.274725274725
Winner: class
Compared with next highest (classless), it's:
92% faster
12.5 times as fast
1.1 order(s) of magnitude faster
92.68% faster
13.67 times as fast
1.14 order(s) of magnitude faster
A LOT FASTER
```

## Benchmark 2

```
class x 93,099,236 ops/sec ±1.02% (88 runs sampled)
classless x 10,524,368 ops/sec ±1.20% (90 runs sampled)
class x 94,362,425 ops/sec ±1.49% (91 runs sampled)
classless x 10,535,684 ops/sec ±1.40% (87 runs sampled)
Fastest is: class
[null]
```

## Profile summary

Tick-class
```
[Summary]:
ticks total nonlib name
6554 69.8% 84.9% JavaScript
441 4.7% 5.7% C++
3 0.0% 0.0% GC
1668 17.8% Shared libraries
```

Tick-classless
```
[Summary]:
ticks total nonlib name
3690 39.4% 40.0% JavaScript
4906 52.3% 53.2% C++
152 1.6% 1.6% GC
152 1.6% Shared libraries
```

5 changes: 1 addition & 4 deletions class-classless/benchmark2.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ suite
.add('class', a)
.add('classless', b)
.on('cycle', (event) => console.log(String(event.target)))
.on('complete', () => {
console.log(`Fastest is: ${suite.filter('fastest').map('name')}`);
console.log(`[${Benchmark.platform.description}]`);
})
.on('complete', () => console.log(`Fastest is: ${suite.filter('fastest').map('name')}`))
.run();
21 changes: 1 addition & 20 deletions class-module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ bench: lint
tail -n 23 out.txt > bench.txt
rm out.txt
npm run benchmark2 > bench2.txt
node --prof prof-class.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-class.txt
rm *.log && rm out.txt
node --prof prof-module.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-module.txt
rm *.log && rm out.txt && touch README.md && rm README.md
touch README.md && rm README.md
echo '## Benchmark' >> README.md
echo ' ' >> README.md
echo '```' >> README.md
Expand All @@ -23,18 +16,6 @@ bench: lint
tail -n 4 bench2.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo '## Profile summary' >> README.md
echo ' ' >> README.md
echo 'Tick-class' >> README.md
echo '```' >> README.md
cat tick-class.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo 'Tick-module' >> README.md
echo '```' >> README.md
cat tick-module.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
rm *.txt
lint: node_modules
npm run lint
Expand Down
54 changes: 16 additions & 38 deletions class-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,35 @@
```
class
Raw:
> 155963.03696303695
> 149779.22077922078
> 148795.2047952048
> 148605.3946053946
Average (mean) 150785.7142857143
> 149900.0999000999
> 142729.27072927073
> 140208.7912087912
> 141633.36663336665
Average (mean) 143617.88211788214
module
Raw:
> 17559.440559440558
> 17163.836163836164
> 17585.414585414586
> 16742.25774225774
Average (mean) 17262.737262737264
> 17664.335664335664
> 16118.88111888112
> 16563.436563436564
> 17655.344655344656
Average (mean) 17000.4995004995
Winner: class
Compared with next highest (module), it's:
88.55% faster
8.73 times as fast
0.94 order(s) of magnitude faster
88.16% faster
8.45 times as fast
0.93 order(s) of magnitude faster
QUITE A BIT FASTER
```

## Benchmark 2

```
class x 94,028,915 ops/sec ±1.08% (86 runs sampled)
module x 16,180,711 ops/sec ±0.80% (92 runs sampled)
class x 91,764,281 ops/sec ±2.30% (87 runs sampled)
module x 15,397,893 ops/sec ±1.94% (83 runs sampled)
Fastest is: class
[null]
```

## Profile summary

Tick-class
```
[Summary]:
ticks total nonlib name
6260 66.8% 81.1% JavaScript
399 4.3% 5.2% C++
8 0.1% 0.1% GC
1652 17.6% Shared libraries
```

Tick-module
```
[Summary]:
ticks total nonlib name
7479 79.5% 82.2% JavaScript
1068 11.4% 11.7% C++
342 3.6% 3.8% GC
304 3.2% Shared libraries
```

5 changes: 1 addition & 4 deletions class-module/benchmark2.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ suite
.add('class', a)
.add('module', b)
.on('cycle', (event) => console.log(String(event.target)))
.on('complete', () => {
console.log(`Fastest is: ${suite.filter('fastest').map('name')}`);
console.log(`[${Benchmark.platform.description}]`);
})
.on('complete', () => console.log(`Fastest is: ${suite.filter('fastest').map('name')}`))
.run();
21 changes: 1 addition & 20 deletions class-prototype/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ bench: lint
tail -n 23 out.txt > bench.txt
rm out.txt
npm run benchmark2 > bench2.txt
node --prof prof-class.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-class.txt
rm *.log && rm out.txt
node --prof prof-prototype.js > /dev/null
node --prof-process *.log > out.txt
grep -A 5 "Summary" -R out.txt > tick-prototype.txt
rm *.log && rm out.txt && touch README.md && rm README.md
touch README.md && rm README.md
echo '## Benchmark' >> README.md
echo ' ' >> README.md
echo '```' >> README.md
Expand All @@ -23,18 +16,6 @@ bench: lint
tail -n 4 bench2.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo '## Profile summary' >> README.md
echo ' ' >> README.md
echo 'Tick-class' >> README.md
echo '```' >> README.md
cat tick-class.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
echo 'Tick-prototype' >> README.md
echo '```' >> README.md
cat tick-prototype.txt >> README.md
echo '```' >> README.md
echo ' ' >> README.md
rm *.txt
lint: node_modules
npm run lint
Expand Down
Loading

0 comments on commit 4f1c50e

Please sign in to comment.