corrade-nucleus-nucleons – Blame information for rev 2
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
2 | office | 1 | #!/usr/bin/env python |
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import os |
||
5 | import copy |
||
6 | import jsbeautifier |
||
7 | options = jsbeautifier.default_options() |
||
8 | options.wrap_line_length = 80 |
||
9 | data = '' |
||
10 | data_min = '' |
||
11 | |||
12 | def beautifier_test_underscore(): |
||
13 | jsbeautifier.beautify(data, options) |
||
14 | |||
15 | def beautifier_test_underscore_min(): |
||
16 | jsbeautifier.beautify(data_min, options) |
||
17 | |||
18 | def report_perf(fn): |
||
19 | import timeit |
||
20 | iter = 50 |
||
21 | time = timeit.timeit(fn + "()", setup="from __main__ import " + fn + "; gc.enable()", number=iter) |
||
22 | print(fn + ": " + str(iter/time) + " cycles/sec") |
||
23 | |||
24 | if __name__ == '__main__': |
||
25 | dirname = os.path.dirname(os.path.abspath(__file__)) |
||
26 | underscore_file = os.path.join(dirname, "../../../", "test/resources/underscore.js") |
||
27 | underscore_min_file = os.path.join(dirname, "../../../", "test/resources/underscore-min.js") |
||
28 | data = copy.copy(''.join(open(underscore_file).readlines())) |
||
29 | data_min = copy.copy(''.join(open(underscore_min_file).readlines())) |
||
30 | |||
31 | # warm up |
||
32 | beautifier_test_underscore() |
||
33 | beautifier_test_underscore_min() |
||
34 | |||
35 | report_perf("beautifier_test_underscore") |
||
36 | report_perf("beautifier_test_underscore_min") |