Skip to content

provide benchmarks for plotly.js #1511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bench/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../.eslintrc",
"env": {
"browser": true
},
"globals": {
"suite": true,
"benchmark": true,
"Plotly": true
}
}
88 changes: 88 additions & 0 deletions bench/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* eslint-env node*/

var pkg = require('../package.json');
var execSync = require('child_process').execSync;

function func(config) {
func.defaultConfig.logLevel = config.LOG_INFO;
func.defaultConfig.browserConsoleLogOptions = {level: 'log'};
config.set(func.defaultConfig);
}

func.defaultConfig = {

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '.',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['browserify', 'benchmark'],
reporters: ['benchmark', 'benchmark-json'],

// list of files / patterns to load in the browser
files: [
'../build/plotly.js',
'./suites/*_bench.js'
],

preprocessors: {
'./suites/*_bench.js': ['browserify']
},

browserify: {
transform: ['../tasks/util/shortcut_paths.js'],
extensions: ['.js'],
debug: true
},

benchmarkJsonReporter: {
pathToJson: '../dist/benchmarks.json',
formatOutput: function(results) {
return {
meta: {
version: pkg.version,
commit: execSync('git rev-parse HEAD').toString().replace('\n', ''),
date: (new Date()).toTimeString()
},
results: results
};
}
},

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// how long will Karma wait for a message from a browser before disconnecting (30 ms)
browserNoActivityTimeout: 30000,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome_WindowSized'],

// custom browser options
//
// window-size values came from observing default size
//
// '--ignore-gpu-blacklist' allow to test WebGL on CI (!!!)
customLaunchers: {
Chrome_WindowSized: {
base: 'Chrome',
flags: ['--window-size=1035,617', '--ignore-gpu-blacklist']
},
Firefox_WindowSized: {
base: 'Firefox',
flags: ['--width=1035', '--height=617']
}
}
};

module.exports = func;
16 changes: 16 additions & 0 deletions bench/suites/lib_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var Lib = require('@src/lib');

suite('Benchmark: lib functions', function() {

benchmark('Lib.cleanNumber', function() {
[
0, 1, 2, 1234.567,
-1, -100, -999.999,
Number.MAX_VALUE, Number.MIN_VALUE, Number.EPSILON,
-Number.MAX_VALUE, -Number.MIN_VALUE, -Number.EPSILON,
NaN, Infinity, -Infinity, null, undefined, new Date(), '',
' ', '\t', '2\t2', '2%2', '2$2', {1: 2}, [1], ['1'], {}, []
]
.forEach(Lib.cleanNumber);
});
});
36 changes: 36 additions & 0 deletions bench/suites/plot_big_data_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var suiteOpts = {
defer: true
};

var benchmarkOpts = {
setup: function() {
this.gd = document.createElement('div');
document.body.appendChild(this.gd);
},
teardown: function() {
Plotly.purge(this.gd);
document.body.removeChild(this.gd);
}
};

suite('Benchmark: plotting large data', function() {
var N = 1e5;

var trace = {
type: 'scattergl',
x: new Array(N),
y: new Array(N)
};

for(var i = 0; i < N; i++) {
trace.x[i] = Math.random();
trace.y[i] = Math.random();
}

benchmark('scattergl 1e5 pts', function(deferred) {
Plotly.plot(this.gd, [trace]).then(function() {
deferred.resolve();
});
}, benchmarkOpts);

}, suiteOpts);
35 changes: 35 additions & 0 deletions bench/suites/plot_mock_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var suiteOpts = {
defer: true
};

var benchmarkOpts = {
setup: function() {
this.gd = document.createElement('div');
document.body.appendChild(this.gd);
},

teardown: function() {
Plotly.purge(this.gd);
document.body.removeChild(this.gd);
}
};

suite('Benchmark: plotting image mocks', function() {

benchmark('17.json', function(deferred) {
var mock = require('@mocks/17.json');

Plotly.plot(this.gd, mock).then(function() {
deferred.resolve();
});
}, benchmarkOpts);

benchmark('contour_match_edges', function(deferred) {
var mock = require('@mocks/contour_match_edges.json');

Plotly.plot(this.gd, mock).then(function() {
deferred.resolve();
});
}, benchmarkOpts);

}, suiteOpts);
169 changes: 169 additions & 0 deletions dist/benchmarks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"meta": {
"version": "1.34.0",
"commit": "086729780205212fb55c33f27b5a845692f94593",
"date": "15:09:07 GMT-0500 (EST)"
},
"results": [
{
"fullName": "Benchmark: lib function--Lib.cleanNumber-Chrome 64.0.3282 (Linux 0.0.0)",
"browser": "Chrome 64.0.3282 (Linux 0.0.0)",
"suite": "Benchmark: lib functions",
"name": "Lib.cleanNumber",
"count": 62762,
"cycles": 6,
"hz": 803408.2211279911,
"hzDeviation": 31147.317130974046,
"mean": 0.000001244697245686623,
"deviation": 4.9312117524292397e-8,
"variance": 2.431684934729625e-15,
"moe": 1.1988174201948626e-8,
"rme": 0.9631397710160021,
"sem": 6.116415409157463e-9,
"sample": [
0.0000012602497585885203,
0.0000013093503985335276,
0.0000012766166385701893,
0.0000012111425111021396,
0.0000012272910779168348,
0.0000012111425111021396,
0.0000012434396447315301,
0.0000012272910779168348,
0.0000012272910779168348,
0.0000012595882115462252,
0.0000012757367783609204,
0.0000012918853451756157,
0.0000012918853451756157,
0.0000012595882115462252,
0.0000013403310456197013,
0.000001404925312878482,
0.0000015179652805813483,
0.0000012918853451756157,
0.0000012272910779168348,
0.0000012434396447315301,
0.0000012434396447315301,
0.0000012111425111021396,
0.0000012272910779168348,
0.0000012434396447315301,
0.0000012111425111021396,
0.0000012434396447315301,
0.0000012587234313756732,
0.000001242790223383576,
0.0000012268570153914788,
0.0000012109238073993817,
0.0000012109238073993817,
0.000001242790223383576,
0.000001242790223383576,
0.000001242790223383576,
0.000001242790223383576,
0.0000012109238073993817,
0.000001242790223383576,
0.0000012268570153914788,
0.0000012268570153914788,
0.0000012268570153914788,
0.0000012109238073993817,
0.0000012109238073993817,
0.000001242790223383576,
0.000001242790223383576,
0.0000012109238073993817,
0.0000012587234313756732,
0.0000012268570153914788,
0.0000012109238073993817,
0.0000012109238073993817,
0.000001242790223383576,
0.0000012268570153914788,
0.0000012109238073993817,
0.0000012109238073993817,
0.0000012109238073993817,
0.0000012268570153914788,
0.0000012109238073993817,
0.000001242790223383576,
0.0000013065230553519646,
0.0000012109238073993817,
0.0000012109238073993817,
0.0000012109238073993817,
0.000001242790223383576,
0.0000012268570153914788,
0.0000012587234313756732,
0.0000011949905994072847
]
},
{
"fullName": "Benchmark: plotting image mock--17.j-on-Chrome 64.0.3282 (Linux 0.0.0)",
"browser": "Chrome 64.0.3282 (Linux 0.0.0)",
"suite": "Benchmark: plotting image mocks",
"name": "17.json",
"count": 2,
"cycles": 2,
"hz": 4.085338175215615,
"hzDeviation": 6.425304603128786,
"mean": 0.24477777777777782,
"deviation": 0.3180914875384823,
"variance": 0.10118219444444447,
"moe": 0.24450632342124673,
"rme": 99.8891017154435,
"sem": 0.10603049584616077,
"sample": [
0.099,
0.0785,
0.0535,
0.0555,
0.0945,
0.1165,
0.1915,
0.5105,
1.0035
]
},
{
"fullName": "Benchmark: plotting image mock--contour_match_edge--Chrome 64.0.3282 (Linux 0.0.0)",
"browser": "Chrome 64.0.3282 (Linux 0.0.0)",
"suite": "Benchmark: plotting image mocks",
"name": "contour_match_edges",
"count": 2,
"cycles": 2,
"hz": 2.142966477881525,
"hzDeviation": 4.4391330743125605,
"mean": 0.4666428571428571,
"deviation": 0.522579875416645,
"variance": 0.27308972619047617,
"moe": 0.48332318680019437,
"rme": 103.57453872956867,
"sem": 0.19751662721707983,
"sample": [
0.096,
0.09,
0.133,
0.269,
0.412,
0.735,
1.5315
]
},
{
"fullName": "Benchmark: plotting large data--cattergl 1e5 pt--Chrome 64.0.3282 (Linux 0.0.0)",
"browser": "Chrome 64.0.3282 (Linux 0.0.0)",
"suite": "Benchmark: plotting large data",
"name": "scattergl 1e5 pts",
"count": 1,
"cycles": 1,
"hz": 1.1568335812262438,
"hzDeviation": 0.6908011723020978,
"mean": 0.8644285714285713,
"deviation": 0.42061853547002936,
"variance": 0.17691995238095234,
"moe": 0.3890212779979738,
"rme": 45.00328781996062,
"sem": 0.1589788630968426,
"sample": [
0.569,
0.443,
1.434,
1.132,
1.329,
0.489,
0.655
]
}
]
}
Loading