Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

[v2] performance: Improve ParseSigned whitespace stripping #279

Merged
merged 2 commits into from Nov 19, 2019

Conversation

pquerna
Copy link
Contributor

@pquerna pquerna commented Nov 16, 2019

  • When profiling some other code, I noticed ParseSigned wasn't as fast as I expected.
  • Adds a benchmark for ParseSigned
  • Replaces regexp to remove whitespace with a string.Builder approach.

benchcmp results for go test -v -run=NONE -bench BenchmarkParseSigned -benchtime=30s -benchmem

benchmark                  old ns/op     new ns/op     delta
BenchmarkParseSigned-4     8184          5461          -33.27%

benchmark                  old allocs     new allocs     delta
BenchmarkParseSigned-4     50             48             -4.00%

benchmark                  old bytes     new bytes     delta
BenchmarkParseSigned-4     3832          3656          -4.59%

@csstaub
Copy link
Collaborator

csstaub commented Nov 19, 2019

This is an excellent improvement, thank you @pquerna!

@csstaub csstaub merged commit f518123 into square:v2 Nov 19, 2019
@mbyczkowski
Copy link
Contributor

@csstaub any plans to port this to master/v3?

mbyczkowski pushed a commit that referenced this pull request Mar 8, 2020
mbyczkowski pushed a commit that referenced this pull request Mar 8, 2020
@mbyczkowski mbyczkowski mentioned this pull request Mar 8, 2020
mbyczkowski pushed a commit that referenced this pull request Mar 8, 2020
mbyczkowski pushed a commit that referenced this pull request Mar 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants