8000 StringParser.CodePoints quadratic scaling · Issue #77 · purescript-contrib/purescript-string-parsers · GitHub
[go: up one dir, main page]

Skip to content
StringParser.CodePoints quadratic scaling #77
Closed
@jamesdbrock

Description

@jamesdbrock

I made a benchmark program for purescript-parsing which benchmarks against this purescript-string-parsers package.

https://github.com/purescript-contrib/purescript-parsing/blob/main/bench/Main.purs

Here are the results of benchmarking many anyDigit

Text.Parsing.StringParser.CodePoints

StringParser.runParser parse23Points
mean   = 746.70 ms
stddev = 12.21 ms
min    = 738.42 ms
max    = 794.27 ms

Text.Parsing.StringParser.CodeUnits

StringParser.runParser parse23Units
mean   = 10.10 ms
stddev = 1.13 ms
min    = 9.46 ms
max    = 24.07 ms

Text.Parsing.Parser.String

runParser parse23
mean   = 44.20 ms
stddev = 6.38 ms
min    = 42.25 ms
max    = 113.16 ms

Data.String.Regex

Regex.match pattern23
mean   = 728.23 μs
stddev = 339.32 μs
min    = 613.72 μs
max    = 2.97 ms

There is something terribly wrong with Text.Parsing.StringParser.CodePoints.anyDigit and I think I know what. The problem is that codePointAt is linear, so many anyDigit then becomes quadratic.

(EDIT deleted notes about stuff not related to this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0