Skip to content

Commit

Permalink
add: pinkie benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Dec 27, 2016
1 parent ba8d16c commit 38ce256
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 38 deletions.
2 changes: 1 addition & 1 deletion benchmark/testCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module.exports = function (name) {
if (count === 0)
return "✓";
else
return "x (" + count + " failing)";
return "x (" + count + " failed)";
};
32 changes: 18 additions & 14 deletions docs/readme.jst.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ I write this lib to research one of my data structure ideas: [docs/lazyTree.md][

# Features

- The best for mobile, minified file is only <%= doc.size %>KB (1.8KB gzipped)
- The best for mobile, gzipped file is only <%= doc.size %>KB
- Supports "uncaught rejection" and "long stack trace", [Comparison][docs/debugHelperComparison.md]
- Designed to work on IE5+ and other major browsers
- Works on IE5+ and other major browsers
- 100% statement and branch test coverage
- Much better performance than the native Promise
- Better CPU and memory performance than the native Promise
- Well commented source code with every Promises/A+ spec
- Highly modularized extra helpers, no pollution to its pure ES6 implements
- Supports ES7 `finally`



Expand Down Expand Up @@ -83,17 +85,18 @@ Arch x64
CPU Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
```

| name | unit tests | coverage | 1ms async task | optional helpers | helpers | min js |
| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ------ |
| [yaku][]@0.17.4 || 100% 100% | 233ms / 108MB || 34 | 4.2KB |
| [yaku.core][]@0.17.4 || 100% 100% | 222ms / 107MB || 28 | 3.4KB |
| [bluebird][]@3.4.6 | x (34 failing) | 99% 96% | 206ms / 79MB | partial | 102 | 54.1KB |
| [es6-promise][]@4.0.5 | x (52 failing) | ? ? | 412ms / 113MB | x | 12 | 6.2KB |
| [native][]@7.2.1 || ? ? | 377ms / 135MB | x | 10 | 0KB |
| [core-js][]@2.4.1 | x (9 failing) | ? ? | 390ms / 141MB | x | 10 | 18.5KB |
| [es6-shim][]@0.35.2 || ? ? | 389ms / 136MB | x | 10 | 54.7KB |
| [q][]@1.4.1 | x (42 failing) | ? ? | 1410ms / 369MB | x | 74 | 15.4KB |
| [my-promise][]@1.1.0 | x (10 failing) | ? ? | 764ms / 232MB | x | 10 | 11.9KB |
| name | unit tests | coverage | 1ms async task | optional helpers | helpers | gzip |
| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ---- |
| [yaku][]@0.17.4 || 100% 100% | 221ms / 108MB || 34 | 1.9KB |
| [yaku.core][]@0.17.4 || 100% 100% | 217ms / 108MB || 28 | 1.6KB |
| [bluebird][]@3.4.6 | x (34 failed) | 99% 96% | 207ms / 81MB | partial | 102 | 15.9KB |
| [es6-promise][]@4.0.5 | x (52 failed) | ? ? | 432ms / 114MB | x | 12 | 2.4KB |
| [pinkie][]@2.0.4 | x (44 failed) | ? ? | 313ms / 135MB || 10 | 1.2KB |
| [native][]@7.2.1 || ? ? | 376ms / 134MB | x | 10 | 0KB |
| [core-js][]@2.4.1 | x (9 failed) | ? ? | 394ms / 142MB | x | 10 | 5KB |
| [es6-shim][]@0.35.2 || ? ? | 390ms / 136MB | x | 10 | 15.5KB |
| [q][]@1.4.1 | x (42 failed) | ? ? | 1432ms / 370MB | x | 74 | 4.6KB |
| [my-promise][]@1.1.0 | x (10 failed) | ? ? | 786ms / 232MB | x | 10 | 3.9KB |

- **unit test**: [promises-aplus-tests][], [promises-es6-tests][], and even the [core-js tests][].

Expand Down Expand Up @@ -238,6 +241,7 @@ Edit the `docs/readme.jst.md` and execute `npm run no` to rebuild the project.
[docs/debugHelperComparison.md]: docs/debugHelperComparison.md
[Bluebird]: https://github.com/petkaantonov/bluebird
[ES6-promise]: https://github.com/jakearchibald/es6-promise
[pinkie]: https://github.com/floatdrop/pinkie
[core-js tests]: https://github.com/ysmood/core-js/tree/promise-yaku
[native]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects
[q]: https://github.com/kriskowal/q
Expand Down
7 changes: 4 additions & 3 deletions nofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var kit = require("nokit");
var _ = kit._;
var Promise = kit.Promise;
kit.require("drives");
var zlib = require("zlib");

module.exports = function (task, option) {
option("-g, --grep <pattern>", "run test that match the pattern", ".");
Expand All @@ -14,7 +15,7 @@ module.exports = function (task, option) {

task("doc", ["code"], "build doc", function () {
var size;
size = kit.statSync("dist/yaku.min.js").size / 1024;
size = zlib.gzipSync(kit.readFileSync("dist/yaku.min.js")).length / 1024;
return kit.warp("src/*.js")
.load(kit.drives.comment2md({
tpl: "docs/readme.jst.md",
Expand Down Expand Up @@ -152,8 +153,8 @@ module.exports = function (task, option) {
+ "\nOS " + (os.platform())
+ "\nArch " + (os.arch())
+ "\nCPU " + (os.cpus()[0].model) + "\n\n"
+ "| name | unit tests | coverage | 1ms async task | optional helpers | helpers | min js |\n"
+ "| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ------ |"
+ "| name | unit tests | coverage | 1ms async task | optional helpers | helpers | gzip |\n"
+ "| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ---- |"
);

var names = _.keys(require("./test/getPromise").map);
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@
"dist/yaku.browser.global.min.js"
],
"devDependencies": {
"bluebird": "3.4.6",
"bluebird": "3.4.7",
"co": "4.6.0",
"core-js": "2.4.1",
"coveralls": "2.11.15",
"es6-promise": "4.0.5",
"es6-shim": "0.35.2",
"eslint": "3.11.1",
"eslint": "3.12.2",
"istanbul": "0.4.5",
"junit": "1.4.5",
"junit": "1.4.7",
"mocha": "3.2.0",
"my-promise": "1.1.0",
"nokit": "0.23.4",
"phantomjs-prebuilt": "2.1.13",
"nokit": "0.23.12",
"phantomjs-prebuilt": "2.1.14",
"pinkie": "2.0.4",
"promises-aplus-tests": "*",
"promises-es6-tests": "*",
"q": "1.4.1",
Expand Down
32 changes: 18 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ I write this lib to research one of my data structure ideas: [docs/lazyTree.md][

# Features

- The best for mobile, minified file is only 4.2KB (1.8KB gzipped)
- The best for mobile, gzipped file is only 1.9KB
- Supports "uncaught rejection" and "long stack trace", [Comparison][docs/debugHelperComparison.md]
- Designed to work on IE5+ and other major browsers
- Works on IE5+ and other major browsers
- 100% statement and branch test coverage
- Much better performance than the native Promise
- Better CPU and memory performance than the native Promise
- Well commented source code with every Promises/A+ spec
- Highly modularized extra helpers, no pollution to its pure ES6 implements
- Supports ES7 `finally`



Expand Down Expand Up @@ -83,17 +85,18 @@ Arch x64
CPU Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
```

| name | unit tests | coverage | 1ms async task | optional helpers | helpers | min js |
| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ------ |
| [yaku][]@0.17.4 || 100% 100% | 233ms / 108MB || 34 | 4.2KB |
| [yaku.core][]@0.17.4 || 100% 100% | 222ms / 107MB || 28 | 3.4KB |
| [bluebird][]@3.4.6 | x (34 failing) | 99% 96% | 206ms / 79MB | partial | 102 | 54.1KB |
| [es6-promise][]@4.0.5 | x (52 failing) | ? ? | 412ms / 113MB | x | 12 | 6.2KB |
| [native][]@7.2.1 || ? ? | 377ms / 135MB | x | 10 | 0KB |
| [core-js][]@2.4.1 | x (9 failing) | ? ? | 390ms / 141MB | x | 10 | 18.5KB |
| [es6-shim][]@0.35.2 || ? ? | 389ms / 136MB | x | 10 | 54.7KB |
| [q][]@1.4.1 | x (42 failing) | ? ? | 1410ms / 369MB | x | 74 | 15.4KB |
| [my-promise][]@1.1.0 | x (10 failing) | ? ? | 764ms / 232MB | x | 10 | 11.9KB |
| name | unit tests | coverage | 1ms async task | optional helpers | helpers | gzip |
| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ---- |
| [yaku][]@0.17.4 || 100% 100% | 221ms / 108MB || 34 | 1.9KB |
| [yaku.core][]@0.17.4 || 100% 100% | 217ms / 108MB || 28 | 1.6KB |
| [bluebird][]@3.4.6 | x (34 failed) | 99% 96% | 207ms / 81MB | partial | 102 | 15.9KB |
| [es6-promise][]@4.0.5 | x (52 failed) | ? ? | 432ms / 114MB | x | 12 | 2.4KB |
| [pinkie][]@2.0.4 | x (44 failed) | ? ? | 313ms / 135MB | x | 10 | 1.2KB |
| [native][]@7.2.1 || ? ? | 376ms / 134MB | x | 10 | 0KB |
| [core-js][]@2.4.1 | x (9 failed) | ? ? | 394ms / 142MB | x | 10 | 5KB |
| [es6-shim][]@0.35.2 || ? ? | 390ms / 136MB | x | 10 | 15.5KB |
| [q][]@1.4.1 | x (42 failed) | ? ? | 1432ms / 370MB | x | 74 | 4.6KB |
| [my-promise][]@1.1.0 | x (10 failed) | ? ? | 786ms / 232MB | x | 10 | 3.9KB |

- **unit test**: [promises-aplus-tests][], [promises-es6-tests][], and even the [core-js tests][].

Expand Down Expand Up @@ -1160,6 +1163,7 @@ Edit the `docs/readme.jst.md` and execute `npm run no` to rebuild the project.
[docs/debugHelperComparison.md]: docs/debugHelperComparison.md
[Bluebird]: https://github.com/petkaantonov/bluebird
[ES6-promise]: https://github.com/jakearchibald/es6-promise
[pinkie]: https://github.com/floatdrop/pinkie
[core-js tests]: https://github.com/ysmood/core-js/tree/promise-yaku
[native]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects
[q]: https://github.com/kriskowal/q
Expand Down
15 changes: 14 additions & 1 deletion test/getPromise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var kit = require("nokit");
var spawnSync = require("child_process").spawnSync;
var zlib = require("zlib");

var map = {
yaku: function () {
Expand Down Expand Up @@ -38,6 +39,18 @@ var map = {
return Promise;
},

pinkie: function () {
var Promise = require("pinkie");
map["pinkie"].optionalHelper = "x";
map["pinkie"].coverage = "? ?";
map["pinkie"].helper = propSize(Promise) + propSize(Promise.prototype);
spawnSync("node_modules/.bin/uglifyjs", [
"-mc", "-o", "dist/pinkie.js", "node_modules/pinkie/index.js"
]);
setSize("pinkie", "dist/pinkie.js");
return Promise;
},

native: function () {
var Promise = global.Promise;
map.native.optionalHelper = "x";
Expand Down Expand Up @@ -120,7 +133,7 @@ function propSize (obj) {
}

function setSize (shim, path) {
var s = kit.statSync(path).size / 1024;
var s = zlib.gzipSync(kit.readFileSync(path)).length / 1024;
map[shim].size = Math.round(s * 10) / 10;
}

0 comments on commit 38ce256

Please sign in to comment.