parsica-php / parsica

Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
https://parsica-php.github.io/
MIT License
405 stars 18 forks source link

⚡️ Make many 400% faster by using while instead of recurse #40

Closed turanct closed 3 years ago

turanct commented 3 years ago

This is 4 times faster than the old many in some basic tests...

Subjects: 5, Assertions: 0, Failures: 0, Errors: 0
suite: 134628ad035def57f08210ae05b1eb88c2d8ce07, date: 2021-03-14, stime: 22:26:52
+-----------+----------------------+-----+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+-------+
| benchmark | subject              | set | revs | its | mem_peak   | best      | mean      | mode      | worst     | stdev    | rstdev | diff  |
+-----------+----------------------+-----+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+-------+
| ManyBench | bench_takeWhile      | 0   | 10   | 10  | 1,825,752b | 97.400μs  | 109.530μs | 106.858μs | 133.200μs | 10.392μs | 9.49%  | 1.00x |
| ManyBench | bench_manySatisfy    | 0   | 10   | 10  | 1,862,264b | 208.700μs | 244.190μs | 225.526μs | 352.000μs | 41.893μs | 17.16% | 2.23x |
| ManyBench | bench_manyChar       | 0   | 10   | 10  | 1,863,008b | 232.100μs | 244.510μs | 237.852μs | 262.400μs | 9.926μs  | 4.06%  | 2.23x |
| ManyBench | bench_oldManySatisfy | 0   | 10   | 10  | 2,959,440b | 712.800μs | 765.140μs | 740.255μs | 910.400μs | 56.543μs | 7.39%  | 6.99x |
| ManyBench | bench_oldManyChar    | 0   | 10   | 10  | 2,960,192b | 733.100μs | 781.460μs | 757.570μs | 878.500μs | 48.064μs | 6.15%  | 7.13x |
+-----------+----------------------+-----+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+-------+
turanct commented 3 years ago

Psalm build is failing and i have no idea why 😬