-
Notifications
You must be signed in to change notification settings - Fork 537
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
Cr/issue 138 #139
Cr/issue 138 #139
Conversation
hmmm. jsperf been down for a while. Makes cross browser profiling and sharing results a bit difficult. Have some results to share, will probably create a few gists. |
@@ -34,7 +34,7 @@ module.exports = function(d3_scale_linear, d3_time, d3_bisect, techan_util_rebin | |||
* @returns {*} | |||
*/ | |||
function scale(x, offset) { | |||
var mappedIndex = dateIndexMap[+x]; | |||
var mappedIndex = dateIndexMap[x.getTime ? x.getTime() : +x]; |
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.
Nice catch here, but after profiling I would prefer:
x instanceof Date ? x.getTime() : +x
Faster still (for me, linux chrome) and handles undefined
and null
s gracefully (without error). I'll add some test cases around the nulls and undefines.
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.
Profile tests: https://gist.github.com/andredumas/7a3277e3cb06c35f4ba34562a873cf35 Thanks for picking this up. As a result will be migrating all the |
The
Just because I hate that js uses |
Interesting, for me The difference is so huge, I almost think there's something wrong with the test... |
Thanks for the contribution @carlos8f |
…string constructor removal, remove Array.join * Adding financetime tests to ensure scale of null and undefined are handled gracefully * Removing String constructor, profiling appears quicker without * Removing usage of Array.join. Array.join is very slow in chrome
fixes issue #138