JairusSW / as-json

The only JSON library you'll need for AssemblyScript. SIMD enabled
MIT License
80 stars 16 forks source link

Identify and fix encoding bugs #63

Closed mattjohnsonpint closed 9 months ago

mattjohnsonpint commented 9 months ago

There are several cases where escape sequences and numeric exponential notation aren't being handled correctly.

Starting with a draft PR to add some tests, several of which are failing. Will follow up with some fixes to pass the tests, and then we can optimize.

mattjohnsonpint commented 9 months ago

Note, the failing test output is sometimes showing the wrong string. That's an as-pect bug, unrelated to this.

mattjohnsonpint commented 9 months ago

All tests are passing now. Review should be focused on perf impact, if any.

mattjohnsonpint commented 9 months ago

Running npm run bench:wasmtime, the main impact seems to be with Parse Object (Vec3), which lost about 75% perf. The other benchmark changes are miniscule. I'll see what I can do.

mattjohnsonpint commented 9 months ago

Better now. Still room for improvement though. (was -75%, now -8%)

mattjohnsonpint commented 9 months ago

Ok, I think I'm done. Here's the benchmarks:

image

Note though that I get wildly different results if I run a single benchmark vs running them all sequentially, so I'm not sure how trustworthy the benchmarks themselves are.

Nonetheless, this is about what I would expect given the changes.

JairusSW commented 9 months ago

Cloned and tested. Looks good and passes tests. Let me pull and then publish as the next version

mattjohnsonpint commented 9 months ago

FYI, import parsing bug has been submitted separately to https://github.com/as-pect/visitor-as/pull/45