-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Misc perf improvements #1772
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
Merged
Merged
Misc perf improvements #1772
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
032cf7c
get rid of Lib.getPlotDiv
alexcjohnson c02204f
short-circuit title draw if there's no title
alexcjohnson b4a2f4d
drop the unneeded initial draw of axes
alexcjohnson b9c33c9
add perf tester to global scope in test dashboard
alexcjohnson ea883e6
cache bounding boxes by node contents instead of by data-bb attr
alexcjohnson 11f4a0e
Merge branch 'master' into misc-perf
alexcjohnson a511bd2
clear bbox cache to fix bar test
alexcjohnson 434dc0e
standardize fail logic in bar test
alexcjohnson d077e32
more failure info in cartesian_interact_test
alexcjohnson 3132624
cleanup cartesian_interact_test a little
alexcjohnson 00c7ad5
remove unused dragElement.init option 'doubleclick'
alexcjohnson 2da3544
cleaner delay pattern in pan tester
alexcjohnson dc4fc32
robustify cartesian_interact_test doubleclicker
alexcjohnson 0129d5a
simplify dragElement cursor handling & remove redundant initInteractions
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
|
||
/* | ||
* timeit: tool for performance testing | ||
* f: function to be tested | ||
* n: number of timing runs | ||
* nchunk: optional number of repetitions per timing run - useful if | ||
* the function is very fast. Note though that if arg is a function | ||
* it will not be re-evaluated within the chunk, only before each chunk. | ||
* arg: optional argument to the function. Can be a function itself | ||
* to provide a changing input to f | ||
*/ | ||
window.timeit = function(f, n, nchunk, arg) { | ||
var times = new Array(n); | ||
var totalTime = 0; | ||
var _arg; | ||
var t0, t1, dt; | ||
|
||
for(var i = 0; i < n; i++) { | ||
if(typeof arg === 'function') _arg = arg(); | ||
else _arg = arg; | ||
|
||
if(nchunk) { | ||
t0 = performance.now(); | ||
for(var j = 0; j < nchunk; j++) { f(_arg); } | ||
t1 = performance.now(); | ||
dt = (t1 - t0) / nchunk; | ||
} | ||
else { | ||
t0 = performance.now(); | ||
f(_arg); | ||
t1 = performance.now(); | ||
dt = t1 - t0; | ||
} | ||
|
||
times[i] = dt; | ||
totalTime += dt; | ||
} | ||
|
||
var first = (times[0]).toFixed(4); | ||
var last = (times[n - 1]).toFixed(4); | ||
times.sort(); | ||
var min = (times[0]).toFixed(4); | ||
var max = (times[n - 1]).toFixed(4); | ||
var median = (times[Math.ceil(n / 2)]).toFixed(4); | ||
var mean = (totalTime / n).toFixed(4); | ||
console.log((f.name || 'function') + ' timing (ms) - min: ' + min + | ||
' max: ' + max + | ||
' median: ' + median + | ||
' mean: ' + mean + | ||
' first: ' + first + | ||
' last: ' + last | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @rreusser would be nice to have something like that in https://github.com/rreusser/plotly-mock-viewer
Moreover, @dfcreative's brilliant ✨ https://www.npmjs.com/package/fps-indicator ✨ would be a nice addition to our dev tools.