Skip to content

!perf: Use string for error src#25

Open
romshark wants to merge 1 commit intomainfrom
hide-error-src
Open

!perf: Use string for error src#25
romshark wants to merge 1 commit intomainfrom
hide-error-src

Conversation

@romshark
Copy link
Copy Markdown
Owner

This PR is related to #24 as an alternative, simpler solution.

Benchmark results:

goos: darwin
goarch: arm64
pkg: github.com/romshark/jscan/v2
                                    │  main.bench  │        hide-error-src.bench         │
                                    │    sec/op    │   sec/op     vs base                │
CalcStats/miniscule_1b__________-10    20.63n ± 0%   14.60n ± 0%  -29.25% (p=0.000 n=10)
CalcStats/tiny_8b_______________-10    27.84n ± 0%   25.70n ± 1%   -7.70% (p=0.000 n=10)
CalcStats/small_336b____________-10    311.8n ± 0%   314.3n ± 0%   +0.82% (p=0.000 n=10)
CalcStats/large_26m_____________-10    13.84m ± 0%   13.91m ± 0%   +0.49% (p=0.000 n=10)
CalcStats/nasa_SxSW_2016_125k___-10    115.4µ ± 0%   117.0µ ± 0%   +1.34% (p=0.000 n=10)
CalcStats/escaped_3k____________-10    1.399µ ± 0%   1.399µ ± 0%        ~ (p=0.265 n=10)
CalcStats/array_int_1024_12k____-10    13.83µ ± 0%   13.62µ ± 0%   -1.48% (p=0.000 n=10)
CalcStats/array_dec_1024_10k____-10    11.73µ ± 4%   11.82µ ± 2%        ~ (p=0.853 n=10)
CalcStats/array_nullbool_1024_5k-10    7.482µ ± 1%   7.519µ ± 1%        ~ (p=0.529 n=10)
CalcStats/array_str_1024_639k___-10    146.4µ ± 0%   146.4µ ± 0%        ~ (p=0.926 n=10)
Valid/deeparray_____________-10       15.680n ± 1%   4.967n ± 0%  -68.32% (p=0.000 n=10)
Valid/unwind_stack__________-10       15.665n ± 1%   4.968n ± 0%  -68.29% (p=0.000 n=10)
Valid/miniscule_1b__________-10       11.430n ± 0%   8.071n ± 0%  -29.39% (p=0.000 n=10)
Valid/tiny_8b_______________-10        17.38n ± 0%   17.07n ± 0%   -1.78% (p=0.000 n=10)
Valid/small_336b____________-10        236.2n ± 0%   234.4n ± 0%   -0.74% (p=0.000 n=10)
Valid/large_26m_____________-10        11.09m ± 0%   11.13m ± 0%   +0.33% (p=0.002 n=10)
Valid/nasa_SxSW_2016_125k___-10        85.25µ ± 0%   85.52µ ± 0%        ~ (p=0.325 n=10)
Valid/escaped_3k____________-10        1.387µ ± 0%   1.390µ ± 0%   +0.22% (p=0.001 n=10)
Valid/array_int_1024_12k____-10        9.135µ ± 1%   9.340µ ± 1%   +2.25% (p=0.000 n=10)
Valid/array_dec_1024_10k____-10        8.672µ ± 0%   8.679µ ± 1%        ~ (p=0.782 n=10)
Valid/array_nullbool_1024_5k-10        3.415µ ± 5%   3.324µ ± 5%   -2.65% (p=0.025 n=10)
Valid/array_str_1024_639k___-10        142.3µ ± 0%   142.6µ ± 0%   +0.22% (p=0.002 n=10)
Yo/bytes-10                                          24.84n ± 0%
Yo/string-10                                         25.16n ± 0%
geomean                                3.038µ        1.792µ       -13.01%

@romshark romshark added major Requires backward incompatible changes performance Improves performance labels Dec 17, 2023
@romshark romshark added this to the v3 milestone Dec 17, 2023
@romshark romshark self-assigned this Dec 17, 2023
The string type is smaller than a byte slice and can be
copied much faster than []byte on modern 64-bit systems.
Drawbacks: this change requires the use of unsafe.
Type Error is no longer required to be type-parameterized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Requires backward incompatible changes performance Improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant