index.js
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* eslint-disable no-unused-expressions */
var bench = require('nanobench')
var acornsrc = require('fs').readFileSync(require.resolve('acorn'))
var lodashsrc = require('fs').readFileSync(require.resolve('lodash'))
var jquerysrc = require('fs').readFileSync(require.resolve('jquery'))
var threesrc = require('fs').readFileSync(require.resolve('three'))
var find = require('../')
// Optimize.
for (var i = 0; i < 5; i++) find(acornsrc).properties
// Has very few undeclared identifiers
bench('acorn × 1', function (b) {
b.start()
find(acornsrc).properties
b.end()
})
bench('acorn × 5', function (b) {
b.start()
for (var i = 0; i < 5; i++) find(acornsrc).properties
b.end()
})
bench('lodash × 1', function (b) {
b.start()
find(lodashsrc).properties
b.end()
})
bench('lodash × 5', function (b) {
b.start()
for (var i = 0; i < 5; i++) find(lodashsrc).properties
b.end()
})
// Has more undeclared identifiers and properties
bench('jquery × 1', function (b) {
b.start()
find(jquerysrc).properties
b.end()
})
bench('jquery × 5', function (b) {
b.start()
for (var i = 0; i < 5; i++) find(jquerysrc).properties
b.end()
})
// is very large
bench('three × 1', function (b) {
b.start()
find(threesrc).identifiers
b.end()
})
bench('three × 5', function (b) {
b.start()
for (var i = 0; i < 5; i++) find(threesrc).identifiers
b.end()
})