Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run more perf tests and on larger files
- Loading branch information
1 parent
77630e5
commit 4807865
Showing
10 changed files
with
3,752 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*global js_beautify: true */ | ||
/*jshint node:true */ | ||
/*jshint unused:false */ | ||
|
||
'use strict'; | ||
|
||
var fs = require('fs'), | ||
SanityTest = require('./sanitytest'), | ||
Benchmark = require('benchmark'), | ||
Urlencoded = require('../lib/unpackers/urlencode_unpacker'), | ||
beautifier = require('../src/index'); | ||
|
||
function node_beautifier_html_tests() { | ||
console.log('Testing performance...'); | ||
var github_css = fs.readFileSync(__dirname + '/../../test/resources/github.css', 'utf8'); | ||
var options = { | ||
wrap_line_length: 80 | ||
}; | ||
|
||
//warm-up | ||
beautifier.html(github_css, options); | ||
|
||
var suite = new Benchmark.Suite(); | ||
|
||
suite.add("css-beautify (github.css)", function() { | ||
beautifier.html(github_css, options); | ||
}) | ||
// add listeners | ||
.on('cycle', function(event) { | ||
console.log(String(event.target)); | ||
}) | ||
.on('error', function(event) { | ||
return 1; | ||
}) | ||
.on('complete', function(event) {}) | ||
.run(); | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
if (require.main === module) { | ||
process.exit(node_beautifier_html_tests()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import copy | ||
import cssbeautifier | ||
options = cssbeautifier.default_options() | ||
options.wrap_line_length = 80 | ||
data = '' | ||
|
||
|
||
def beautifier_test_github_css(): | ||
cssbeautifier.beautify(data, options) | ||
|
||
|
||
def report_perf(fn): | ||
import timeit | ||
iter = 5 | ||
time = timeit.timeit( | ||
fn + | ||
"()", | ||
setup="from __main__ import " + | ||
fn + | ||
"; gc.enable()", | ||
number=iter) | ||
print(fn + ": " + str(iter / time) + " cycles/sec") | ||
|
||
|
||
if __name__ == '__main__': | ||
dirname = os.path.dirname(os.path.abspath(__file__)) | ||
github_file = os.path.join( | ||
dirname, "../", "test/resources/github.css") | ||
data = copy.copy(''.join(open(github_file).readlines())) | ||
|
||
# warm up | ||
beautifier_test_github_css() | ||
|
||
report_perf("beautifier_test_github_css") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.