Skip to content

Commit a153697

Browse files
Merge pull request #68 from dalenberg/benchmark
test: add benchmark test
2 parents 97d6868 + 0e75740 commit a153697

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"precommit": "lint-staged",
1717
"prepublishOnly": "npm run clean && npm run build:unmin && npm run build:min",
1818
"release": "standard-version --no-verify",
19-
"test": "mocha"
19+
"test": "mocha",
20+
"test:benchmark": "node ./test/benchmark.js"
2021
},
2122
"repository": {
2223
"type": "git",
@@ -40,6 +41,7 @@
4041
"devDependencies": {
4142
"@commitlint/cli": "^6.1.0",
4243
"@commitlint/config-conventional": "^6.1.0",
44+
"benchmark": "2.1.4",
4345
"coveralls": "^3.0.0",
4446
"eslint": "^4.18.0",
4547
"eslint-plugin-prettier": "^2.6.0",

test/benchmark.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
var Benchmark = require('benchmark');
4+
var helpers = require('./helpers/');
5+
var Parser = require('../');
6+
7+
var suite = new Benchmark.Suite();
8+
var mocks = helpers.mocks;
9+
10+
suite
11+
.add('html-to-react - Single', function() {
12+
Parser(mocks.html.single);
13+
})
14+
.add('html-to-react - Multiple', function() {
15+
Parser(mocks.html.multiple);
16+
})
17+
.add('html-to-react - Complex', function() {
18+
Parser(mocks.html.complex);
19+
})
20+
.on('cycle', function(event) {
21+
process.stdout.write(String(event.target) + '\n');
22+
})
23+
.run({
24+
minSamples: 100,
25+
delay: 2
26+
});

0 commit comments

Comments
 (0)