-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
81 lines (67 loc) · 1.96 KB
/
test.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const fs = require('fs');
const acorn = require('acorn'),
esprima = require('esprima'),
sbs = require('sidebyside');
const tokenizer = require('./dist/out.min.js');
const basic = '2>>>2';
const simple = `/test/.match('foo');`;
const string = '"foo"\'foo\'\'bar\'';
const strings = `
function bar () {
var foo = "a string";
var bar = "another string";
}
`;
const code = `
// testing 123
function (foo, bar) {
return foo + a + 355;
var a, b;
var baz = "foo";
/* this is a test */
var boo = 123 + 'fds';
/* this is
* another
* test
*/
/test/.match("YOLO!");
var faz = 'bar';
return baz + foo + faz - bar || 'baz';
}
`;
//const tabs = fs.readFileSync('./samples/across-tabs.js').toString();
const somejqueryfile = fs.readFileSync('./samples/somejqueryfile.js').toString();
//const anotherjqueryfile = fs.readFileSync('./samples/anotherjqueryfile.js').toString();
const jquery = fs.readFileSync('./samples/jquery.js').toString();
const react = fs.readFileSync('./samples/react.js').toString();
//const somestrings = fs.readFileSync('./samples/strings.js').toString();
const bunchofcomments = fs.readFileSync('./samples/bunchofcomments.js').toString();
//const lodash = fs.readFileSync('./samples/lodash.min.js').toString();
const angular = fs.readFileSync('./samples/angular.min.js').toString();
const test = code;
let a = [],
b = [],
c = [];
console.log('lilboy');
let s = Date.now();
let n = 0;
let tokens;
tokens = tokenizer(test);
for (token of tokens) { a.push(token); n++; }
console.log(`${Date.now() - s}ms; ${n} tokens`);
console.log('');
console.log('acorn');
n = 0;
s = Date.now();
tokens = acorn.tokenizer(test);
for (token of tokens) { b.push(token); n++; }
console.log(`${Date.now() - s}ms; ${n} tokens`);
console.log('');
console.log('esprima');
n = 0;
s = Date.now();
tokens = esprima.tokenize(test);
for (token of tokens) { c.push(token); n++; }
console.log(`${Date.now() - s}ms; ${n} tokens`);
console.log('');
//sbs(a, b);