cats-parse
cats-parse copied to clipboard
Add json string parsing
close #433
benchmark of this code:
[info] Benchmark (test) Mode Cnt Score Error Units
[info] BarBench.catsParseParse N/A avgt 5 ≈ 10⁻⁴ ms/op
[info] BarBench.fastparseParse N/A avgt 5 ≈ 10⁻⁴ ms/op
[info] BarBench.jawnParse N/A avgt 5 ≈ 10⁻⁴ ms/op
[info] BarBench.parboiled2Parse N/A avgt 5 ≈ 10⁻⁴ ms/op
[info] BarBench.parsleyParseCold N/A avgt 5 0.062 ± 0.001 ms/op
[info] Bla25Bench.catsParseParse N/A avgt 5 42.636 ± 0.282 ms/op
[info] Bla25Bench.fastparseParse N/A avgt 5 15.629 ± 0.143 ms/op
[info] Bla25Bench.jawnParse N/A avgt 5 7.452 ± 0.043 ms/op
[info] Bla25Bench.parboiled2Parse N/A avgt 5 16.390 ± 0.087 ms/op
[info] Bla25Bench.parsleyParseCold N/A avgt 5 30.787 ± 0.158 ms/op
[info] CountriesBench.catsParseParse N/A avgt 5 9.264 ± 0.033 ms/op
[info] CountriesBench.fastparseParse N/A avgt 5 5.052 ± 0.025 ms/op
[info] CountriesBench.jawnParse N/A avgt 5 1.257 ± 0.008 ms/op
[info] CountriesBench.parboiled2Parse N/A avgt 5 2.773 ± 0.012 ms/op
[info] CountriesBench.parsleyParseCold N/A avgt 5 11.621 ± 0.392 ms/op
[info] Qux2Bench.catsParseParse N/A avgt 5 11.809 ± 0.049 ms/op
[info] Qux2Bench.fastparseParse N/A avgt 5 6.461 ± 0.047 ms/op
[info] Qux2Bench.jawnParse N/A avgt 5 2.176 ± 0.006 ms/op
[info] Qux2Bench.parboiled2Parse N/A avgt 5 5.452 ± 0.006 ms/op
[info] Qux2Bench.parsleyParseCold N/A avgt 5 10.108 ± 0.189 ms/op
[info] StringInBenchmarks.linearMatchIn foo avgt 5 78.571 ± 0.797 ns/op
[info] StringInBenchmarks.linearMatchIn broad avgt 5 93375.006 ± 3022.573 ns/op
[info] StringInBenchmarks.oneOfParse foo avgt 5 94.752 ± 0.751 ns/op
[info] StringInBenchmarks.oneOfParse broad avgt 5 1095.949 ± 25.393 ns/op
[info] StringInBenchmarks.radixMatchIn foo avgt 5 59.749 ± 0.037 ns/op
[info] StringInBenchmarks.radixMatchIn broad avgt 5 742.420 ± 0.113 ns/op
[info] StringInBenchmarks.stringInSParse foo avgt 5 94.084 ± 0.254 ns/op
[info] StringInBenchmarks.stringInSParse broad avgt 5 1004.531 ± 1.304 ns/op
[info] StringInBenchmarks.stringInVParse foo avgt 5 97.028 ± 13.912 ns/op
[info] StringInBenchmarks.stringInVParse broad avgt 5 1082.276 ± 1.764 ns/op
[info] Ugh10kBench.catsParseParse N/A avgt 5 83.426 ± 0.073 ms/op
[info] Ugh10kBench.fastparseParse N/A avgt 5 45.765 ± 0.156 ms/op
[info] Ugh10kBench.jawnParse N/A avgt 5 11.227 ± 0.049 ms/op
[info] Ugh10kBench.parboiled2Parse N/A avgt 5 27.397 ± 0.086 ms/op
[info] Ugh10kBench.parsleyParseCold N/A avgt 5 76.632 ± 0.270 ms/op
seems like the performance of the json benchmark is rather worse with this version of the parser. A big change with using a charIn to check for valid json characters rather just anyChar, which I guess may be the problem. I'll see if I can get it back to where it was before.
Codecov Report
Merging #438 (3948f44) into main (d7ed829) will increase coverage by
0.13%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## main #438 +/- ##
==========================================
+ Coverage 94.98% 95.12% +0.13%
==========================================
Files 9 10 +1
Lines 1436 1476 +40
Branches 324 327 +3
==========================================
+ Hits 1364 1404 +40
Misses 72 72
Impacted Files | Coverage Δ | |
---|---|---|
...hared/src/main/scala/cats/parse/strings/Json.scala | 100.00% <100.00%> (ø) |
|
...shared/src/main/scala/cats/parse/Accumulator.scala | 97.56% <0.00%> (-2.44%) |
:arrow_down: |
core/shared/src/main/scala/cats/parse/Parser.scala | 94.49% <0.00%> (+0.08%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@regadas this is ready if you would have time to review.
I will post updated benchmarks but it is basically as fast as the previous benchmarks (but should be faster for escaped strings, but the benchmark doesn't stress those now).
The nice thing is that users of the library can now very easily make a quick and dirty json parser since the hard parts (numbers and strings) are provided here.
No problem! Thanks for taking the time to review.