Skip to content

Commit bf41bab

Browse files
committed
Lib: Remove markTime method
1 parent 0f110e1 commit bf41bab

File tree

11 files changed

+19
-60
lines changed

11 files changed

+19
-60
lines changed

src/lib/index.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
var d3 = require('d3');
1313

1414
var lib = module.exports = {};
15+
var config = require('../plot_api/plot_config');
1516

1617
lib.nestedProperty = require('./nested_property');
1718
lib.isPlainObject = require('./is_plain_object');
@@ -100,25 +101,24 @@ lib.pauseEvent = function(e) {
100101

101102
// set VERBOSE to true to get a lot more logging and tracing
102103
lib.VERBOSE = false;
103-
104-
// first markTime call will return time from page load
105-
lib.TIMER = new Date().getTime();
106-
107104
// console.log that only runs if VERBOSE is on
108105
lib.log = function() {
109106
if(lib.VERBOSE) console.log.apply(console, arguments);
107+
if(config.logging > 1) {
108+
console.log.apply(console, arguments);
109+
}
110110
};
111111

112-
/**
113-
* markTime - for debugging, mark the number of milliseconds
114-
* since the previous call to markTime and log arbitrary info too
115-
*/
116-
lib.markTime = function(v) {
117-
if(!lib.VERBOSE) return;
118-
var t2 = new Date().getTime();
119-
console.log(v, t2 - lib.TIMER, '(msec)');
120-
if(lib.VERBOSE === 'trace') console.trace();
121-
lib.TIMER = t2;
112+
lib.warn = function() {
113+
if(config.logging > 0) {
114+
console.warn.apply(console, arguments);
115+
}
116+
};
117+
118+
lib.error = function() {
119+
if(config.logging > 0) {
120+
console.error.apply(console, arguments);
121+
}
122122
};
123123

124124
// constrain - restrict a number v to be between v0 and v1
@@ -271,18 +271,17 @@ lib.syncOrAsync = function(sequence, arg, finalStep) {
271271
var ret, fni;
272272

273273
function continueAsync() {
274-
lib.markTime('async done ' + fni.name);
275274
return lib.syncOrAsync(sequence, arg, finalStep);
276275
}
276+
277277
while(sequence.length) {
278278
fni = sequence.splice(0, 1)[0];
279279
ret = fni(arg);
280-
// lib.markTime('done calling '+fni.name)
280+
281281
if(ret && ret.then) {
282282
return ret.then(continueAsync)
283283
.then(undefined, lib.promiseError);
284284
}
285-
lib.markTime('sync done ' + fni.name);
286285
}
287286

288287
return finalStep && finalStep(arg);
@@ -434,6 +433,7 @@ lib.addStyleRule = function(selector, styleString) {
434433
styleSheet.addRule(selector, styleString, 0);
435434
}
436435
else console.warn('addStyleRule failed');
436+
else lib.warn('addStyleRule failed');
437437
};
438438

439439
lib.getTranslate = function(element) {

src/plot_api/plot_api.js

-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ var xmlnsNamespaces = require('../constants/xmlns_namespaces');
5151
*
5252
*/
5353
Plotly.plot = function(gd, data, layout, config) {
54-
Lib.markTime('in plot');
5554

5655
gd = getGraphDiv(gd);
5756

@@ -223,11 +222,9 @@ Plotly.plot = function(gd, data, layout, config) {
223222
}
224223
}
225224

226-
Lib.markTime('done with bar/box adjustments');
227225

228226
// calc and autorange for errorbars
229227
ErrorBars.calc(gd);
230-
Lib.markTime('done ErrorBars.calc');
231228

232229
// TODO: autosize extra for text markers
233230
return Lib.syncOrAsync([
@@ -282,7 +279,6 @@ Plotly.plot = function(gd, data, layout, config) {
282279

283280
// styling separate from drawing
284281
Plots.style(gd);
285-
Lib.markTime('done Plots.style');
286282

287283
// show annotations and shapes
288284
Shapes.drawAll(gd);
@@ -312,7 +308,6 @@ Plotly.plot = function(gd, data, layout, config) {
312308
function cleanUp() {
313309
// now we're REALLY TRULY done plotting...
314310
// so mark it as done and let other procedures call a replot
315-
Lib.markTime('done plot');
316311
gd.emit('plotly_afterplot');
317312
}
318313

@@ -641,9 +636,7 @@ function cleanLayout(layout) {
641636

642637
// sanitize rgb(fractions) and rgba(fractions) that old tinycolor
643638
// supported, but new tinycolor does not because they're not valid css
644-
Lib.markTime('finished rest of cleanLayout, starting color');
645639
Color.clean(layout);
646-
Lib.markTime('finished cleanLayout color.clean');
647640

648641
return layout;
649642
}

src/plots/cartesian/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ exports.plot = function(gd) {
8181
// plot all traces of this type on this subplot at once
8282
var cdModule = getCdModule(cdSubplot, _module);
8383
_module.plot(gd, subplotInfo, cdModule);
84-
85-
Lib.markTime('done ' + (cdModule[0] && cdModule[0][0].trace.type));
8684
}
8785
}
8886
};

src/traces/contour/plot.js

-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ var BOTTOMSTART = [1, 9, 13, 104, 713],
5151
SADDLEREMAINDER = {1: 4, 2: 8, 4: 1, 7: 13, 8: 2, 11: 14, 13: 7, 14: 11};
5252

5353
function plotOne(gd, plotinfo, cd) {
54-
Lib.markTime('in Contour.plot');
5554
var trace = cd[0].trace,
5655
x = cd[0].x,
5756
y = cd[0].y,
@@ -103,8 +102,6 @@ function plotOne(gd, plotinfo, cd) {
103102
makeFills(plotGroup, pathinfo, perimeter, contours);
104103
makeLines(plotGroup, pathinfo, contours);
105104
clipGaps(plotGroup, plotinfo, cd[0], perimeter);
106-
107-
Lib.markTime('done Contour.plot');
108105
}
109106

110107
function emptyPathinfo(contours, plotinfo, cd0) {

src/traces/heatmap/calc.js

-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ var maxRowLength = require('./max_row_length');
2323

2424

2525
module.exports = function calc(gd, trace) {
26-
Lib.markTime('start convert x&y');
27-
2826
// prepare the raw data
2927
// run makeCalcdata on x and y even for heatmaps, in case of category mappings
3028
var xa = Axes.getFromId(gd, trace.xaxis || 'x'),
@@ -45,8 +43,6 @@ module.exports = function calc(gd, trace) {
4543
xa._minDtick = 0;
4644
ya._minDtick = 0;
4745

48-
Lib.markTime('done convert x&y');
49-
5046
if(isHist) {
5147
var binned = histogram2dCalc(gd, trace);
5248
x = binned.x;

src/traces/heatmap/colorbar.js

-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,4 @@ module.exports = function colorbar(gd, cd) {
4141
.range(scl.map(function(v) { return v[1]; })))
4242
.filllevels({start: zmin, end: zmax, size: (zmax - zmin) / 254})
4343
.options(trace.colorbar)();
44-
45-
Lib.markTime('done colorbar');
4644
};

src/traces/heatmap/plot.js

-8
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ module.exports = function(gd, plotinfo, cdheatmaps) {
2828

2929
// From http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/
3030
function plotOne(gd, plotinfo, cd) {
31-
Lib.markTime('in Heatmap.plot');
32-
3331
var trace = cd[0].trace,
3432
uid = trace.uid,
3533
xa = plotinfo.x(),
@@ -286,8 +284,6 @@ function plotOne(gd, plotinfo, cd) {
286284
return setColor(z00 + xinterp.frac * dx + yinterp.frac * (dy + xinterp.frac * dxy));
287285
}
288286

289-
Lib.markTime('done init png');
290-
291287
if(zsmooth) { // best or fast, works fastest with imageData
292288
var pxIndex = 0,
293289
pixels = new Uint8Array(imageWidth * imageHeight * 4);
@@ -359,8 +355,6 @@ function plotOne(gd, plotinfo, cd) {
359355
}
360356
}
361357

362-
Lib.markTime('done filling png');
363-
364358
rcount = Math.round(rcount / pixcount);
365359
gcount = Math.round(gcount / pixcount);
366360
bcount = Math.round(bcount / pixcount);
@@ -391,6 +385,4 @@ function plotOne(gd, plotinfo, cd) {
391385
y: top,
392386
preserveAspectRatio: 'none'
393387
});
394-
395-
Lib.markTime('done showing png');
396388
}

src/traces/histogram2d/calc.js

-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ module.exports = function calc(gd, trace) {
3333
if(x.length > serieslen) x.splice(serieslen, x.length - serieslen);
3434
if(y.length > serieslen) y.splice(serieslen, y.length - serieslen);
3535

36-
Lib.markTime('done convert data');
3736

3837
// calculate the bins
3938
if(trace.autobinx || !('xbins' in trace)) {
@@ -54,7 +53,6 @@ module.exports = function calc(gd, trace) {
5453
}
5554
trace._input.ybins = trace.ybins;
5655
}
57-
Lib.markTime('done autoBin');
5856

5957
// make the empty bin array & scale the map
6058
z = [];
@@ -138,7 +136,6 @@ module.exports = function calc(gd, trace) {
138136
}
139137

140138

141-
Lib.markTime('done making bins');
142139
// put data into bins
143140
for(i = 0; i < serieslen; i++) {
144141
n = Lib.findBin(x[i], xbins);
@@ -154,7 +151,6 @@ module.exports = function calc(gd, trace) {
154151
if(normfunc) {
155152
for(m = 0; m < ny; m++) normfunc(z[m], total, xinc, yinc[m]);
156153
}
157-
Lib.markTime('done binning');
158154

159155
return {
160156
x: x,

src/traces/scatter/calc.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ var calcMarkerColorscale = require('./marker_colorscale_calc');
2121
module.exports = function calc(gd, trace) {
2222
var xa = Axes.getFromId(gd, trace.xaxis || 'x'),
2323
ya = Axes.getFromId(gd, trace.yaxis || 'y');
24-
Lib.markTime('in Scatter.calc');
2524

26-
var x = xa.makeCalcdata(trace, 'x');
27-
Lib.markTime('finished convert x');
28-
29-
var y = ya.makeCalcdata(trace, 'y');
30-
Lib.markTime('finished convert y');
25+
var x = xa.makeCalcdata(trace, 'x'),
26+
y = ya.makeCalcdata(trace, 'y');
3127

3228
var serieslen = Math.min(x.length, y.length),
3329
marker,
@@ -111,11 +107,8 @@ module.exports = function calc(gd, trace) {
111107
yOptions.padded = false;
112108
}
113109

114-
Lib.markTime('ready for Axes.expand');
115110
Axes.expand(xa, x, xOptions);
116-
Lib.markTime('done expand x');
117111
Axes.expand(ya, y, yOptions);
118-
Lib.markTime('done expand y');
119112

120113
// create the "calculated data" to plot
121114
var cd = new Array(serieslen);

src/traces/scatter/colorbar.js

-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,4 @@ module.exports = function colorbar(gd, cd) {
4848
.range(scl.map(function(v) { return v[1]; })))
4949
.filllevels({start: cmin, end: cmax, size: (cmax - cmin) / 254})
5050
.options(marker.colorbar)();
51-
52-
Lib.markTime('done colorbar');
5351
};

src/traces/surface/colorbar.js

-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ module.exports = function colorbar(gd, cd) {
4242
.range(scl.map(function(v) { return v[1]; })))
4343
.filllevels({start: zmin, end: zmax, size: (zmax - zmin) / 254})
4444
.options(trace.colorbar)();
45-
46-
Lib.markTime('done colorbar');
4745
};

0 commit comments

Comments
 (0)