Skip to content

Commit

Permalink
feat: improve string (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
quagmt authored Nov 1, 2024
1 parent 1d8c752 commit 4ea866a
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 220 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fuzz-all:
@sh scripts/fuzz-all.sh $(fuzzTime)

bench:
@go test -bench=BenchmarkString -benchmem -benchmem -memprofile=mem.out -cpuprofile=cpu.out -run NONE
@go test -bench=BenchmarkGVString -benchmem -benchmem -memprofile=mem.out -cpuprofile=cpu.out -run NONE

# https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line
%:
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

bench:
# @go test -bench BenchmarkMarshalJSON -benchmem -memprofile mem.out -cpuprofile cpu.out -run NONE
@go test -bench BenchmarkParse -benchmem -count=10 -run NONE > new.txt
@go test -bench BenchmarkMarshalJSON -benchmem -count=10 -run NONE > new.txt

bench-udec:
@rm -f bench-udec.txt
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ BenchmarkParse/1234567890-32
BenchmarkParse/0.1234567890123456879-32 44339668 26.45 ns/op 0 B/op 0 allocs/op
BenchmarkParseFallBack/123456789123456789123456.1234567890123456-32 2805122 473.3 ns/op 192 B/op 6 allocs/op
BenchmarkParseFallBack/111222333444555666777888999.1234567890123456789-32 2442004 500.8 ns/op 216 B/op 6 allocs/op
BenchmarkString/1234567890123456789.1234567890123456879-32 12797790 98.69 ns/op 48 B/op 1 allocs/op
BenchmarkString/0.1234567890123456879-32 18784728 57.20 ns/op 24 B/op 1 allocs/op
BenchmarkString/1234567890123456789.1234567890123456879-32 14577884 76.50 ns/op 48 B/op 1 allocs/op
BenchmarkString/0.1234567890123456879-32 41109242 40.02 ns/op 24 B/op 1 allocs/op
BenchmarkStringFallBack/123456789123456789123456.1234567890123456-32 4147044 256.2 ns/op 208 B/op 4 allocs/op
BenchmarkStringFallBack/111222333444555666777888999.1234567890123456789-32 3808071 313.3 ns/op 208 B/op 4 allocs/op
# Marshal/Unmarshal
BenchmarkMarshalJSON/1234567890123456789.1234567890123456879-32 15796016 96.75 ns/op 48 B/op 1 allocs/op
BenchmarkMarshalJSON/0.1234567890123456879-32 22017422 54.95 ns/op 24 B/op 1 allocs/op
BenchmarkMarshalJSON/1234567890123456789.1234567890123456879-32 13965998 77.22 ns/op 48 B/op 1 allocs/op
BenchmarkMarshalJSON/0.1234567890123456879-32 24039360 43.57 ns/op 24 B/op 1 allocs/op
BenchmarkMarshalJSON/12345678901234567891234567890123456789.1234567890123456879-32 3445560 291.6 ns/op 320 B/op 5 allocs/op
BenchmarkUnmarshalJSON/1234567890123456789.1234567890123456879-32 15943234 73.77 ns/op 0 B/op 0 allocs/op
BenchmarkUnmarshalJSON/123456.123456-32 46983879 26.55 ns/op 0 B/op 0 allocs/op
Expand All @@ -98,8 +98,8 @@ Parse/1234567890123456789.1234567890123456879-32
Parse/0.1234567890123456879-32 262.30n ± 17% 25.93n ± 3% -90.11% (p=0.000 n=10)
ParseFallBack/123456789123456789123456.1234567890123456-32 373.2n ± 13% 418.3n ± 7% +12.08% (p=0.000 n=10)
ParseFallBack/111222333444555666777888999.1234567890123456789-32 418.5n ± 5% 453.4n ± 9% +8.33% (p=0.003 n=10)
String/1234567890123456789.1234567890123456879-32 284.45n ± 26% 97.61n ± 11% -65.68% (p=0.000 n=10)
String/0.1234567890123456879-32 173.80n ± 15% 58.94n ± 15% -66.09% (p=0.000 n=10)
String/1234567890123456789.1234567890123456879-32 284.45n ± 26% 77.35n ± 10% -72.81% (p=0.000 n=10)
String/0.1234567890123456879-32 173.80n ± 15% 42.60n ± 6% -75.49% (p=0.000 n=10)
StringFallBack/123456789123456789123456.1234567890123456-32 394.1n ± 15% 268.4n ± 22% -31.90% (p=0.000 n=10)
StringFallBack/111222333444555666777888999.1234567890123456789-32 353.4n ± 26% 307.3n ± 6% -13.04% (p=0.004 n=10)
Add/1234567890123456789.1234567890123456879.Add(1111.1789)-32 384.65n ± 10% 10.87n ± 3% -97.18% (p=0.000 n=10)
Expand All @@ -118,8 +118,8 @@ DivFallback/12345679012345679890123456789.1234567890123456789.Div(999999)-32
DivFallback/1234.Div(12345679012345679890123456789.1234567890123456789)-32 242.1n ± 87% 292.9n ± 4% ~ (p=0.481 n=10)
Pow/1.01.Pow(10)-32 724.70n ± 31% 40.83n ± 3% -94.37% (p=0.000 n=10)
Pow/1.01.Pow(100)-32 1.367µ ± 8% 1.062µ ± 7% -22.28% (p=0.000 n=10)
MarshalJSON/1234567890123456789.1234567890123456879-32 451.65n ± 6% 96.56n ± 7% -78.62% (p=0.000 n=10)
MarshalJSON/0.1234567890123456879-32 204.70n ± 7% 54.62n ± 8% -73.32% (p=0.000 n=10)
MrshalJSON/1234567890123456789.1234567890123456879-32 451.65n ± 6% 72.53n ± 12% -83.94% (p=0.000 n=10)
MarshalJSON/0.1234567890123456879-32 204.70n ± 7% 43.49n ± 7% -78.75% (p=0.000 n=10)
MarshalJSON/12345678901234567891234567890123456789.1234567890123456879-32 523.6n ± 15% 358.4n ± 7% -31.55% (p=0.000 n=10)
UnmarshalJSON/1234567890123456789.1234567890123456879-32 488.90n ± 10% 73.75n ± 1% -84.92% (p=0.000 n=10)
UnmarshalJSON/0.1234567890123456879-32 449.70n ± 9% 40.97n ± 1% -90.89% (p=0.000 n=10)
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/bench-ss.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ BenchmarkString/0.1234567890123456879-32 64
BenchmarkString/0.1234567890123456879-32 6106804 182.6 ns/op 80 B/op 4 allocs/op
BenchmarkString/0.1234567890123456879-32 8340056 170.9 ns/op 80 B/op 4 allocs/op
BenchmarkString/0.1234567890123456879-32 7816422 144.5 ns/op 80 B/op 4 allocs/op
BenchmarkString/12345.1234567890123456789-32 4406620 262.8 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 4715979 240.2 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 5084666 232.1 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 5469702 250.0 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 5063049 242.4 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 4717598 225.0 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 4795444 241.4 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 4823866 251.8 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 5811994 236.4 ns/op 176 B/op 5 allocs/op
BenchmarkString/12345.1234567890123456789-32 4685367 242.8 ns/op 176 B/op 5 allocs/op
BenchmarkStringFallBack/123456789123456789123456.1234567890123456-32 3008487 382.0 ns/op 272 B/op 5 allocs/op
BenchmarkStringFallBack/123456789123456789123456.1234567890123456-32 4295414 329.6 ns/op 272 B/op 5 allocs/op
BenchmarkStringFallBack/123456789123456789123456.1234567890123456-32 3388437 372.2 ns/op 272 B/op 5 allocs/op
Expand Down
Loading

0 comments on commit 4ea866a

Please sign in to comment.