Skip to content

Commit

Permalink
docs: add pta in the benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent RENARD authored and Laurent RENARD committed Oct 25, 2019
1 parent d4cb97d commit d410a37
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 30 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ Each framework runs with its default settings.

Here are the result of different test frameworks on my developer machine (MacBook Pro, 2.7GH i5) with node 12 :

| | zora@3.1.0 | tape@4.11.2 | Jest@24.9.0 | AvA@2.4.0 | Mocha@6.2.1|
|--------|:------------:|:-----------: |:-------------:|:------------:|:----------:|
|Library | 102ms | 1240ms | 2835ms | 1888ms | 1349ms |
|Web app | 134ms | 3523ms | 4084ms | 2900ms | 3696ms |
|API | 187ms | 12586ms | 7380ms | 3900ms | 12766ms |
| | zora@3.1.0 | pta@0.1.0 | tape@4.11.2 | Jest@24.9.0 | AvA@2.4.0 | Mocha@6.2.1|
|--------|:------------:|:------------:|:------------:|:-------------:|:------------:|:----------:|
|Library | 102ms | 231ms | 1240ms | 2835ms | 1888ms | 1349ms |
|Web app | 134ms | 278ms | 3523ms | 4084ms | 2900ms | 3696ms |
|API | 187ms | 331ms | 12586ms | 7380ms | 3900ms | 12766ms |

Of course as any benchmark, it may not cover your use case and you should probably run your own tests before you draw any conclusion.

Expand All @@ -83,9 +83,9 @@ In my opinions:

As a result zora is much smaller of an install according to [packagephobia](https://packagephobia.now.sh) than all the others test frameworks

| | zora | tape | Jest | AvA | Mocha|
|--------|:------------:|:-----------:|:-------------:|:------------:|:------------:|
|Install size | [![zora](https://packagephobia.now.sh/badge?p=zora)](https://packagephobia.now.sh/result?p=zora) | [![tape](https://packagephobia.now.sh/badge?p=tape)](https://packagephobia.now.sh/result?p=tape) | [![jes](https://packagephobia.now.sh/badge?p=jest)](https://packagephobia.now.sh/result?p=jest) | [![ava](https://packagephobia.now.sh/badge?p=ava)](https://packagephobia.now.sh/result?p=ava) | [![mocha](https://packagephobia.now.sh/badge?p=mocha)](https://packagephobia.now.sh/result?p=mocha) |
| | zora | pta |tape | Jest | AvA | Mocha|
|--------|:------------:|:------------:|:-----------:|:-------------:|:------------:|:------------:|
|Install size | [![zora](https://packagephobia.now.sh/badge?p=zora)](https://packagephobia.now.sh/result?p=zora) | [![pta](https://packagephobia.now.sh/badge?p=pta)](https://packagephobia.now.sh/result?p=pta) | [![tape](https://packagephobia.now.sh/badge?p=tape)](https://packagephobia.now.sh/result?p=tape) | [![jes](https://packagephobia.now.sh/badge?p=jest)](https://packagephobia.now.sh/result?p=jest) | [![ava](https://packagephobia.now.sh/badge?p=ava)](https://packagephobia.now.sh/result?p=ava) | [![mocha](https://packagephobia.now.sh/badge?p=mocha)](https://packagephobia.now.sh/result?p=mocha) |

### Reporting is handled with another process (TAP aware)

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/ava/test/test1.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

const test = require('ava');
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
test('test ' + i, async function (assert) {
await new Promise(resolve => {
setTimeout(()=>resolve(),50);
setTimeout(()=>resolve(),100);
});
assert.truthy(Math.random() * 100 > 3);
assert.truthy(Math.random() * 100 > 5);
});
}
6 changes: 3 additions & 3 deletions benchmarks/jest/test/test1.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

describe('add', function () {
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
it('should test',async function () {
await new Promise(resolve => {
setTimeout(()=>resolve(),50);
setTimeout(()=>resolve(),100);
});
expect(Math.random() * 100 > 3).toBeTruthy();
expect(Math.random() * 100 > 5).toBeTruthy();
});
}
});
6 changes: 3 additions & 3 deletions benchmarks/mocha/test/test1.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

const assert = require('assert');
describe('test file', function() {
for(let i=0; i < 8;i++){
for(let i=0; i < 10;i++){
it('test ' + i, function(done) {
setTimeout(()=>{
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > 5);
done();
},50);
},100);
});
}
});
6 changes: 3 additions & 3 deletions benchmarks/tape/test/test1.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

const test = require('tape');
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
test('test ' + i, function (assert) {
setTimeout(()=>{
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > 5);
assert.end();
},50);
},100);
});
}
6 changes: 3 additions & 3 deletions benchmarks/zora/test/test1.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

module.exports =(({test}) => {
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
test('test ' + i, async function (assert) {
await new Promise(resolve => {
setTimeout(()=>resolve(),50);
setTimeout(()=>resolve(),100);
});
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > 5);
});
}});
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"bench:mocha": "time mocha ./benchmarks/mocha/test/",
"bench:tape": "time node ./benchmarks/tape/index",
"bench:jest": "time jest",
"bench:pta": "time pta benchmarks/zora/test/*.js",
"test:unit": "rollup -c ./rollup/test.js | node",
"test:sample": "node ./test/samples/index.js",
"test": "npm run test:unit && npm run test:sample",
Expand All @@ -51,6 +52,7 @@
"esm": "^3.2.25",
"jest": "^24.9.0",
"mocha": "^6.2.1",
"pta": "^0.1.0",
"rollup": "^1.24.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
Expand Down
15 changes: 8 additions & 7 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ const fs = require('fs');
const path = require('path');

const filesCount = 12;
const testCount = 8;
const waitTime = 50;
const testCount = 10;
const waitTime = 100;
const errorRate = 5;

const zoraCode = `
module.exports =(({test}) => {
Expand All @@ -12,7 +13,7 @@ for (let i = 0; i < ${testCount}; i++) {
await new Promise(resolve => {
setTimeout(()=>resolve(),${waitTime});
});
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > ${errorRate});
});
}});
`;
Expand All @@ -24,7 +25,7 @@ for (let i = 0; i < ${testCount}; i++) {
await new Promise(resolve => {
setTimeout(()=>resolve(),${waitTime});
});
assert.truthy(Math.random() * 100 > 3);
assert.truthy(Math.random() * 100 > ${errorRate});
});
}
`;
Expand All @@ -35,7 +36,7 @@ describe('test file', function() {
for(let i=0; i < ${testCount};i++){
it('test ' + i, function(done) {
setTimeout(()=>{
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > ${errorRate});
done();
},${waitTime});
});
Expand All @@ -48,7 +49,7 @@ const test = require('tape');
for (let i = 0; i < ${testCount}; i++) {
test('test ' + i, function (assert) {
setTimeout(()=>{
assert.ok(Math.random() * 100 > 3);
assert.ok(Math.random() * 100 > ${errorRate});
assert.end();
},${waitTime});
});
Expand All @@ -62,7 +63,7 @@ describe('add', function () {
await new Promise(resolve => {
setTimeout(()=>resolve(),${waitTime});
});
expect(Math.random() * 100 > 3).toBeTruthy();
expect(Math.random() * 100 > ${errorRate}).toBeTruthy();
});
}
});
Expand Down

0 comments on commit d410a37

Please sign in to comment.