-
Notifications
You must be signed in to change notification settings - Fork 569
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
Use ES6 Map/Set when possible (2x speedup in compress). #47
Comments
Thanks for the idea and the tests. I've always wanted lz-stringto be compliant with every javascript engine, hence the avoidance of new JavaScript stuff. I've also done a few tests to work with arrays instead of Strings but I probably didn't push them far enough. If you have the code with ES6 Map/Set, can you push it through a pull request ? I can probably have a look into it this week. Detecting the feature shouldn't be that hard. ALSO: Can you take a minute and pass the jsperf of the latest pre-release (https://github.com/pieroxy/lz-string/releases) with all the IEs you have at hand? I can't decide myself to release it (faster on FF/Chrome, slower on IE) but I lack data on IE and my tests were performed in a VM which is probable messing with performances. |
I don't have any IE versions, sorry. |
I've had my share of surprises on jsperf with code that would OBVIOUSLY be faster but was slower on some browsers for reasons I couldn't be bothered to investigate. I'd start with doing a couple of jsperf with this one as it looks like it's going to be beneficial for #46 as well. We'll move forward if tests are a clear win on all platform supported. Moving forward meaning:
NOTE: I've just released v1.4.0 which clean up the wrapper methods. If you can rebase on top of that it would be great. Either you do the jsperf yourself or you push a pull request and I'll deal with the jsperf. And thanks for the hard work ! |
I made a pull request for #46. |
I'll start working on that one starting next week. We'll obviously start with a jsperf ;-) |
With this issue, of course =). |
Allright, it took longer than expected, as usual. Here is a glimpse of what could be LZString 1.5: http://jsperf.com/lz-string-1-4-3-vs-1-5 Can you take it with as many devices as possible? So far, unsurprisingly, old browsers take a hit, new ones are happy. A few exceptions:
FYI, the code: c8ac062 |
@pieroxy Ping on this. Looking forward to the big perf fix! What's the status on 1.5? Do you just need people to test it? How can we help? |
Ah yes, I've been lazy (and busy). There are a couple of things I need to do on LZ-String and this is one of them. The version 1.5 wasn't all that impressive. The speedup was impressive but the loss due to encapsulation on the old / unsupported browsers was too high. I'll redo it shortly in another way. |
@pieroxy: ping? |
Yup, I'll get around to it shortly now that jsperf is up again. |
Here's a wrapper around Map that implements just enough functionality for lz-string's purposes when Map isn't available.
|
ping |
Using ES6
Map
forcontext_dictionary
and ES6Set
(orMap
) forcontext_dictionaryToCreate
instead of a plainObject
speeds up the compression twice in v8.See #46 (comment) for test results.
Map
andSet
are supported in current Chrome and Firefox versions.IE11 has partial support for them, but that should be enough: see «Map → basic functionality» here: https://kangax.github.io/compat-table/es6/
I haven't tested the speed in Firefox and IE11, but it shouldn't be worse than using an
Object
.Supporting old browsers would require some kind of feature detection.
The text was updated successfully, but these errors were encountered: