Strumenta / antlr-kotlin

Support for Kotlin as a target for ANTLR 4
Apache License 2.0
221 stars 47 forks source link

Apply minor optimizations to StringCharStream and JS BitSet #171

Closed lppedd closed 6 months ago

lppedd commented 6 months ago

The optimizations done for StringCharStream reduce up to half the time spent indexing code points in very large strings.

I've tested it with 4+ megabytes text files.

lppedd commented 6 months ago

@ftomassetti the code looks "worse" than before, but the benefits are pretty amazing for StringCharStream.

On my laptop - with a 4 megabytes file - I get:

Target Before After
JVM 11.529621 ms 4.075896 ms
JS 41.52782 ms 25.09781 ms
WASM 109.095989 ms 40.703107 ms
mingwX64 19.490488 ms 8.587009 ms

Ken mentioned performance in the email, and I think we have a lot of room for improvement.
Many micro-optimizations summed together might give us quite a boost.

ftomassetti commented 6 months ago

Added a few minor comments

ftomassetti commented 6 months ago

Thank you @lppedd