pdf.js/worker/console.js

28 lines
612 B
JavaScript
Raw Normal View History

2011-09-13 02:37:33 +09:00
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2011-06-27 03:55:27 +09:00
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2011-07-06 15:06:45 +09:00
'use strict';
2011-06-27 03:55:27 +09:00
var consoleTimer = {};
var console = {
log: function log() {
var args = Array.prototype.slice.call(arguments);
postMessage({
2011-07-06 15:06:45 +09:00
action: 'log',
2011-09-06 09:42:58 +09:00
data: args
2011-06-27 03:55:27 +09:00
});
},
2011-07-06 15:06:45 +09:00
2011-06-27 03:55:27 +09:00
time: function(name) {
consoleTimer[name] = Date.now();
},
2011-07-06 15:06:45 +09:00
2011-06-27 03:55:27 +09:00
timeEnd: function(name) {
var time = consoleTimer[name];
if (time == null) {
2011-07-06 15:06:45 +09:00
throw 'Unkown timer name ' + name;
2011-06-27 03:55:27 +09:00
}
2011-07-06 15:06:45 +09:00
this.log('Timer:', name, Date.now() - time);
2011-06-27 03:55:27 +09:00
}
2011-07-06 15:06:45 +09:00
};