Skip to content

Commit b532cb0

Browse files
committed
add scattergl tests
1 parent 94b2fe0 commit b532cb0

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
var createGraphDiv = require('../assets/create_graph_div');
2+
var delay = require('../assets/delay');
3+
var Plotly = require('../../../lib/core');
4+
var PlotlyScattergl = require('../../../lib/scattergl');
5+
var writeRawDataAsCSV = require('./assets/post_process').writeRawDataAsCSV;
6+
7+
var gd = createGraphDiv();
8+
9+
var tests = [{
10+
n: 1000
11+
}, {
12+
n: 2000
13+
}, {
14+
n: 4000
15+
}, {
16+
n: 8000
17+
}, {
18+
n: 16000
19+
}, {
20+
n: 32000
21+
}, {
22+
n: 64000
23+
}, {
24+
n: 128000
25+
}, {
26+
n: 256000
27+
}, {
28+
n: 512000
29+
}, {
30+
n: 1024000
31+
}];
32+
33+
tests.forEach(function(spec, index) {
34+
describe('Performance test scattergl | size:' + spec.n, function() {
35+
'use strict';
36+
37+
Plotly.register(PlotlyScattergl);
38+
39+
const samples = Array.from({ length: 9 }, (_, i) => i);
40+
const nTimes = samples.length - 1;
41+
42+
var y = Float64Array.from({ length: spec.n }, (_, i) => i * Math.cos(Math.sqrt(i)));
43+
44+
var mock = {
45+
data: [{
46+
type: 'scattergl',
47+
mode: 'markers',
48+
y: y
49+
}],
50+
layout: {
51+
width: 900,
52+
height: 400
53+
}
54+
};
55+
56+
var startTime, endTime;
57+
58+
beforeEach(function(done) {
59+
startTime = performance.now();
60+
61+
// Wait for actual rendering to complete
62+
requestAnimationFrame(function() {
63+
requestAnimationFrame(function() {
64+
endTime = performance.now();
65+
done();
66+
});
67+
});
68+
69+
Plotly.newPlot(gd, mock);
70+
});
71+
72+
afterEach(function(done) {
73+
delay(100)().then(done);
74+
});
75+
76+
samples.forEach(function(t) {
77+
it('should graph scattergl traces | turn: ' + t, function() {
78+
var delta = endTime - startTime;
79+
80+
if(t === 0) {
81+
tests[index].raw = [];
82+
}
83+
tests[index].raw[t] = delta;
84+
85+
if(t === nTimes && index === tests.length - 1) {
86+
writeRawDataAsCSV('scattergl', tests);
87+
}
88+
});
89+
});
90+
});
91+
});

0 commit comments

Comments
 (0)