Adding code to track expression rendering time

This commit is contained in:
Jeff Avallone 2015-01-01 11:57:11 -05:00
parent 37fca15bc8
commit 491c9535a9
2 changed files with 15 additions and 1 deletions

View File

@ -484,6 +484,15 @@ describe('regexper.js', function() {
.done();
});
it('tracks the total rendering time', function(done) {
this.regexper.renderRegexp('example expression')
.then(() => {
expect(window._gaq.push).toHaveBeenCalledWith(['_trackTiming', 'visualization', 'total time', jasmine.any(Number)]);
}, fail)
.finally(done)
.done();
});
});
describe('when the rendering is cancelled', function() {

View File

@ -125,7 +125,8 @@ export default class Regexper {
}
renderRegexp(expression) {
var parseError = false;
var parseError = false,
startTime, endTime;
if (this.running) {
let deferred = Q.defer();
@ -141,6 +142,7 @@ export default class Regexper {
this.state = 'is-loading';
window._gaq.push(['_trackEvent', 'visualization', 'start']);
startTime = new Date().getTime();
this.running = new Parser(this.svgContainer);
@ -161,6 +163,9 @@ export default class Regexper {
this.updateLinks();
this.displayWarnings(this.running.warnings);
window._gaq.push(['_trackEvent', 'visualization', 'complete']);
endTime = new Date().getTime();
window._gaq.push(['_trackTiming', 'visualization', 'total time', endTime - startTime]);
})
.then(null, message => {
if (message === 'Render cancelled') {