]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | var Linter = require("../../lib/linter").Linter, |
2 | fs = require("fs"); | |
3 | ||
4 | var config = require("../../conf/eslint-recommended"); | |
5 | ||
6 | var large = fs.readFileSync(__dirname + "/large.js", "utf8"), | |
7 | medium = fs.readFileSync(__dirname + "/medium.js", "utf8"), | |
8 | small = fs.readFileSync(__dirname + "/small.js", "utf8"); | |
9 | ||
10 | var runs = { | |
11 | large: large, | |
12 | medium: medium, | |
13 | small: small | |
14 | }; | |
15 | var linter = new Linter(); | |
16 | ||
17 | benchmark.runs = runs; | |
18 | benchmark(Boolean, 1); | |
19 | ||
20 | function benchmark(grep, times) { | |
21 | console.profile("all"); | |
22 | for(var key in runs) { | |
23 | if(grep(key)) { | |
24 | console.time(key); | |
25 | console.profile(key); | |
26 | run(runs[key], times); | |
27 | console.profileEnd(key); | |
28 | console.timeEnd(key); | |
29 | } | |
30 | } | |
31 | console.profileEnd("all"); | |
32 | } | |
33 | ||
34 | function run(content, times) { | |
35 | while(times--) { | |
36 | linter.verify(content, config); | |
37 | } | |
38 | } |