Fix painful bug in eventlogging code

Change-Id: I3026aadcb28e7a8325137214512163558cccf2db
This commit is contained in:
Mark Holmquist 2014-01-07 16:22:18 -08:00
parent 055ccb8c27
commit 3547f17960
2 changed files with 5 additions and 5 deletions

View file

@ -907,20 +907,20 @@
* Signal the end of an event being profiled and send the * Signal the end of an event being profiled and send the
* eventlogging message. * eventlogging message.
* @param {number} id Should be the value returned from profileStart * @param {number} id Should be the value returned from profileStart
* @param {boolean} [includeTime] For testing, whether to include the time in the message. Time is zero otherwise. * @param {boolean} [fakeTime] For testing, whether to fake the time in the message. Time is zero if so.
*/ */
MMVP.profileEnd = function ( id, includeTime ) { MMVP.profileEnd = function ( id, fakeTime ) {
var msg; var msg;
if ( profiling[id] ) { if ( profiling[id] ) {
msg = profiling[id]; msg = profiling[id];
msg.milliseconds = includeTime ? Date.now() - msg.start : 0; msg.milliseconds = Date.now() - msg.start;
delete msg.start; delete msg.start;
mw.log( mw.log(
mmvLogActions['profile-' + msg.action + '-end'] mmvLogActions['profile-' + msg.action + '-end']
.replace( /\$1/g, id ) .replace( /\$1/g, id )
.replace( /\$2/g, msg.milliseconds ) .replace( /\$2/g, fakeTime ? 0 : msg.milliseconds )
); );
if ( mw.eventLog ) { if ( mw.eventLog ) {

View file

@ -208,7 +208,7 @@
assert.strictEqual( pid, i, 'nonce-style profile IDs come in order.' ); assert.strictEqual( pid, i, 'nonce-style profile IDs come in order.' );
expectedMsg = test[2].replace( /\$1/g, i ).replace( /\$2/g, 0 ); expectedMsg = test[2].replace( /\$1/g, i ).replace( /\$2/g, 0 );
viewer.profileEnd( pid, false ); viewer.profileEnd( pid, true );
} }
mw.log = backupLog; mw.log = backupLog;