use console.time for mss benchmarking

This commit is contained in:
Dane Springmeyer 2012-12-21 17:49:53 -08:00
parent 16db1c5b03
commit 8846bfbbcd

View File

@ -27,38 +27,35 @@ carto.Renderer.prototype.renderMSS = function render(data, callback) {
var output = [];
var styles = [];
var time = +new Date();
if (env.benchmark) console.time('Parsing MSS');
var parser = (carto.Parser(env)).parse(data);
if (env.benchmark) {
console.warn('Parsing time: ' + (new Date() - time) + 'ms');
}
time = +new Date();
if (env.benchmark) console.timeEnd('Parsing MSS');
if (env.benchmark) console.time('Rule generation');
var rule_list = parser.toList(env);
if (env.benchmark) console.timeEnd('Rule generation');
if (env.benchmark) console.time('Rule inheritance');
var rules = inheritRules(rule_list,env);
if (env.benchmark) {
console.warn('Rule generation time: ' + (new Date() - time) + 'ms');
}
time = +new Date();
if (env.benchmark) console.timeEnd('Rule inheritance');
if (env.benchmark) console.time('Style sort');
var sorted = sortStyles(rules,env);
if (env.benchmark) {
console.warn('Sorted time: ' + (new Date() - time) + 'ms');
}
var time = +new Date();
if (env.benchmark) console.timeEnd('Style sort');
if (env.benchmark) console.time('Total Style generation');
for (var k = 0, rule, style_name; k < sorted.length; k++) {
rule = sorted[k];
style_name = 'layer' + (rule.attachment !== '__default__' ? '-' + rule.attachment : '');
style_name = 'style-' + (rule.attachment !== '__default__' ? '-' + rule.attachment : '');
styles.push(style_name);
var time_to_xml = +new Date();
var bench_name = '\tStyle "'+style_name+'" (#'+k+') toXML';
if (env.benchmark) console.time(bench_name);
// env.effects can be modified by this call
output.push(carto.tree.Style.toXML(style_name, rule.attachment, rule, env));
if (env.benchmark) {
console.warn('Calling toXML for style "' + style_name + '" (#'+k + '): ' + (new Date() - time_to_xml) + 'ms');
}
}
if (env.benchmark) {
console.warn('Total Style toXML time: ' + (new Date() - time) + 'ms');
if (env.benchmark) console.timeEnd(bench_name);
}
if (env.benchmark) console.timeEnd('Total Style generation');
if (env.errors) return callback(env.errors);
return callback(null, output.join('\n'));
}