pull/3/head
Amio 2018-06-23 17:54:52 +08:00
rodzic 59008c1f67
commit ae09b1be51
4 zmienionych plików z 43 dodań i 0 usunięć

Wyświetl plik

@ -2,6 +2,9 @@
Fast, handcraft, pure JavaScript badge generator.
- 🌀 No dependeny.
- ⚡️ 200K+ ops on average. (see [benchamrks](#Benchmarks))
## Usage
### Badge Service
@ -48,6 +51,16 @@ const svgString = badgen({
})
```
## Benchmarks
`npm run bench` on my iMac5K(Late 2014), 3.5G i5:
```bash
generate by short params x 420,831 ops/sec ±1.03% (87 runs sampled)
generate by long params x 167,862 ops/sec ±1.21% (90 runs sampled)
generate by full params x 245,303 ops/sec ±1.48% (92 runs sampled)
```
## License
ISC @ Amio

12
bench/index.js 100644
Wyświetl plik

@ -0,0 +1,12 @@
const { Suite } = require('benchmark')
const badgen = require('..')
new Suite().add('generate by short params', function () {
badgen({ subject: 'b', status: 'p' })
}).add('generate by long params ', function () {
badgen({ subject: 'build-build-build', status: 'passing-passing-passing' })
}).add('generate by full params ', function () {
badgen({ subject: 'license', status: 'Apache-2.0', color: 'blue' })
}).on('cycle', function (event) {
console.log(String(event.target))
}).run()

16
package-lock.json wygenerowano
Wyświetl plik

@ -199,6 +199,16 @@
"tweetnacl": "^0.14.3"
}
},
"benchmark": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
"dev": true,
"requires": {
"lodash": "^4.17.4",
"platform": "^1.3.3"
}
},
"bind-obj-methods": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/bind-obj-methods/-/bind-obj-methods-2.0.0.tgz",
@ -4357,6 +4367,12 @@
"find-up": "^1.0.0"
}
},
"platform": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.5.tgz",
"integrity": "sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q==",
"dev": true
},
"pluralize": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz",

Wyświetl plik

@ -7,12 +7,14 @@
"main": "lib/index.js",
"scripts": {
"lint": "standard",
"bench": "node bench/index.js",
"test": "tap test/*.spec.js --reporter spec",
"start": "node service.js",
"predeploy": "now rm badgen --safe -y -T badgen",
"deploy": "now -T badgen --public && now -T badgen alias"
},
"devDependencies": {
"benchmark": "^2.1.4",
"find-my-way": "^1.13.0",
"lru-cache": "^4.1.3",
"standard": "^11.0.1",