Skip to content

Commit 9f60776

Browse files
committed
wait for actual rendering to complete
1 parent d7bf5b5 commit 9f60776

File tree

7 files changed

+84
-28
lines changed

7 files changed

+84
-28
lines changed

test/jasmine/performance_tests/bar_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ tests.forEach(function(spec, index) {
4545
}
4646
};
4747

48-
var startTime;
48+
var startTime, endTime;
4949

5050
beforeEach(function(done) {
51-
startTime = Date.now();
51+
startTime = performance.now();
52+
53+
// Wait for actual rendering to complete
54+
requestAnimationFrame(function() {
55+
requestAnimationFrame(function() {
56+
endTime = performance.now();
57+
done();
58+
});
59+
});
5260

53-
Plotly.newPlot(gd, mock).then(done);
61+
Plotly.newPlot(gd, mock);
5462
});
5563

5664
afterEach(function(done) {
@@ -62,7 +70,7 @@ tests.forEach(function(spec, index) {
6270

6371
samples.forEach(function(t) {
6472
it('should graph bar traces | turn: ' + t, function() {
65-
var delta = Date.now() - startTime;
73+
var delta = endTime - startTime;
6674

6775
if(t === 0) {
6876
// console.log('________________________________');

test/jasmine/performance_tests/box_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ tests.forEach(function(spec, index) {
4646
}
4747
};
4848

49-
var startTime;
49+
var startTime, endTime;
5050

5151
beforeEach(function(done) {
52-
startTime = Date.now();
52+
startTime = performance.now();
53+
54+
// Wait for actual rendering to complete
55+
requestAnimationFrame(function() {
56+
requestAnimationFrame(function() {
57+
endTime = performance.now();
58+
done();
59+
});
60+
});
5361

54-
Plotly.newPlot(gd, mock).then(done);
62+
Plotly.newPlot(gd, mock);
5563
});
5664

5765
afterEach(function(done) {
@@ -63,7 +71,7 @@ tests.forEach(function(spec, index) {
6371

6472
samples.forEach(function(t) {
6573
it('should graph box traces | turn: ' + t, function() {
66-
var delta = Date.now() - startTime;
74+
var delta = endTime - startTime;
6775

6876
if(t === 0) {
6977
// console.log('________________________________');

test/jasmine/performance_tests/contour_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ tests.forEach(function(spec, index) {
5656
}
5757
};
5858

59-
var startTime;
59+
var startTime, endTime;
6060

6161
beforeEach(function(done) {
62-
startTime = Date.now();
62+
startTime = performance.now();
63+
64+
// Wait for actual rendering to complete
65+
requestAnimationFrame(function() {
66+
requestAnimationFrame(function() {
67+
endTime = performance.now();
68+
done();
69+
});
70+
});
6371

64-
Plotly.newPlot(gd, mock).then(done);
72+
Plotly.newPlot(gd, mock);
6573
});
6674

6775
afterEach(function(done) {
@@ -73,7 +81,7 @@ tests.forEach(function(spec, index) {
7381

7482
samples.forEach(function(t) {
7583
it('should graph contour traces | turn: ' + t, function() {
76-
var delta = Date.now() - startTime;
84+
var delta = endTime - startTime;
7785

7886
if(t === 0) {
7987
// console.log('________________________________');

test/jasmine/performance_tests/heatmap_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ tests.forEach(function(spec, index) {
5656
}
5757
};
5858

59-
var startTime;
59+
var startTime, endTime;
6060

6161
beforeEach(function(done) {
62-
startTime = Date.now();
62+
startTime = performance.now();
63+
64+
// Wait for actual rendering to complete
65+
requestAnimationFrame(function() {
66+
requestAnimationFrame(function() {
67+
endTime = performance.now();
68+
done();
69+
});
70+
});
6371

64-
Plotly.newPlot(gd, mock).then(done);
72+
Plotly.newPlot(gd, mock);
6573
});
6674

6775
afterEach(function(done) {
@@ -73,7 +81,7 @@ tests.forEach(function(spec, index) {
7381

7482
samples.forEach(function(t) {
7583
it('should graph heatmap traces | turn: ' + t, function() {
76-
var delta = Date.now() - startTime;
84+
var delta = endTime - startTime;
7785

7886
if(t === 0) {
7987
// console.log('________________________________');

test/jasmine/performance_tests/histogram_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ tests.forEach(function(spec, index) {
4545
}
4646
};
4747

48-
var startTime;
48+
var startTime, endTime;
4949

5050
beforeEach(function(done) {
51-
startTime = Date.now();
51+
startTime = performance.now();
52+
53+
// Wait for actual rendering to complete
54+
requestAnimationFrame(function() {
55+
requestAnimationFrame(function() {
56+
endTime = performance.now();
57+
done();
58+
});
59+
});
5260

53-
Plotly.newPlot(gd, mock).then(done);
61+
Plotly.newPlot(gd, mock);
5462
});
5563

5664
afterEach(function(done) {
@@ -62,7 +70,7 @@ tests.forEach(function(spec, index) {
6270

6371
samples.forEach(function(t) {
6472
it('should graph histogram traces | turn: ' + t, function() {
65-
var delta = Date.now() - startTime;
73+
var delta = endTime - startTime;
6674

6775
if(t === 0) {
6876
// console.log('________________________________');

test/jasmine/performance_tests/image_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,20 @@ tests.forEach(function(spec, index) {
6363
}
6464
};
6565

66-
var startTime;
66+
var startTime, endTime;
6767

6868
beforeEach(function(done) {
69-
startTime = Date.now();
69+
startTime = performance.now();
70+
71+
// Wait for actual rendering to complete
72+
requestAnimationFrame(function() {
73+
requestAnimationFrame(function() {
74+
endTime = performance.now();
75+
done();
76+
});
77+
});
7078

71-
Plotly.newPlot(gd, mock).then(done);
79+
Plotly.newPlot(gd, mock);
7280
});
7381

7482
afterEach(function(done) {
@@ -80,7 +88,7 @@ tests.forEach(function(spec, index) {
8088

8189
samples.forEach(function(t) {
8290
it('should graph image traces | turn: ' + t, function() {
83-
var delta = Date.now() - startTime;
91+
var delta = endTime - startTime;
8492

8593
if(t === 0) {
8694
// console.log('________________________________');

test/jasmine/performance_tests/scatter_test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,20 @@ tests.forEach(function(spec, index) {
4343
}
4444
};
4545

46-
var startTime;
46+
var startTime, endTime;
4747

4848
beforeEach(function(done) {
49-
startTime = Date.now();
49+
startTime = performance.now();
50+
51+
// Wait for actual rendering to complete
52+
requestAnimationFrame(function() {
53+
requestAnimationFrame(function() {
54+
endTime = performance.now();
55+
done();
56+
});
57+
});
5058

51-
Plotly.newPlot(gd, mock).then(done);
59+
Plotly.newPlot(gd, mock);
5260
});
5361

5462
afterEach(function(done) {
@@ -60,7 +68,7 @@ tests.forEach(function(spec, index) {
6068

6169
samples.forEach(function(t) {
6270
it('should graph scatter traces | turn: ' + t, function() {
63-
var delta = Date.now() - startTime;
71+
var delta = endTime - startTime;
6472

6573
if(t === 0) {
6674
// console.log('________________________________');

0 commit comments

Comments
 (0)