parsica icon indicating copy to clipboard operation
parsica copied to clipboard

Performance: ~250% faster JSON Parser

Open mhsdesign opened this issue 4 years ago • 0 comments

related: #17 inspired by this regex:

/^
  "[^"\\]*              # double quoted strings with possibly escaped double quotes
    (?:
      \\.               # escaped character (quote)
      [^"\\]*           # unrolled loop following Jeffrey E.F. Friedl
    )*
  "
/x

i implemented an unrolled loop in combination with takeWhile. (the last use of the deprecated zeroOrMore was also removed) this leads to a big performance boost from ca ~250%(without xdebug) - ~330%(with xdebug) - both without opcache.

before: bench_json_encode: 4.133μs bench_Parsica_JSON: 4.109ms bench_basemax_jpophp: 432.128μs

after: bench_json_encode: 3.744μs bench_Parsica_JSON: 1.662ms bench_basemax_jpophp: 401.154μs

mhsdesign avatar Nov 21 '21 13:11 mhsdesign