Can you add benchmarking for cloning? #124
matthew-dean
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not trying to micro-optimize, but at the same time, I've been leaning more and more on this library in my current project just to not have to think about performance in most of my data structure.
My question is around cloning performance. I notice that, for example, in the HashMap
clone()
method, it does afor
/of
over the iterator. (What's also interesting / weird, is that cloning in many structures creates a specific class instead of creating an instance ofthis.constructor
, which means that it's somewhat an unreliable clone, if classes are extended. Can you explain that choice?)A while back, I set up some tests for Map / Set because I was kind of baffled to learn that, in Chromium, creating a
Map
by passing in aMap
was slower than iterating over each element. I passed that issue over to the Chromium team, but in the process of doing those tests and some experimentation, I found that, currently, there's even a fastest-path iteration in Chrome, which is awhile
loop, like:This is currently decently faster than
for
/of
in Chromium. In Firefox, as of today,for
/of
andwhile
are roughly equal, and in Safari, they actually seem to have figured out that cloning a map from another map is as simple as an internal memory copy, sonew Map(mapToClone)
is orders of magnitude faster than both other engines.So, anyways, seeing cloning in the performance tests would be great. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions