Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove regexp for performance #66

Merged
merged 1 commit into from
May 6, 2015
Merged

Conversation

markrechler
Copy link
Contributor

While the regex version reads easier, the performance difference is very noticeable even for these easy replacements.

master:
BenchmarkManyDifferentSensors          1    1928148881 ns/op
BenchmarkOneBigTimer           1    1845274355 ns/op
BenchmarkLotsOfTimers          1    1902944310 ns/op
BenchmarkParseLine    300000          5568 ns/op

non_regex:
BenchmarkManyDifferentSensors          1    1838807819 ns/op
BenchmarkOneBigTimer           1    1769153610 ns/op
BenchmarkLotsOfTimers          1    1853729588 ns/op
BenchmarkParseLine   1000000          1131 ns/op

@markrechler
Copy link
Contributor Author

@jehiah this is ready for review. Thanks.

c := bucket[i]
switch {
// a-z or A-Z or 0-9 or - or . or _
case (c >= 97 && c <= 122) || (c >= 65 && c <= 90) || (c >= 48 && c <= 57) || c == 45 || c == 46 || c == 95:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be able to do something like

c >= byte('a')

instead of

c >= 97

for dat readability

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and out of the shadows stood @davemarchevsky

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted, thanks @davemarchevsky.

@jehiah
Copy link
Member

jehiah commented May 6, 2015

🔨 ?

@markrechler
Copy link
Contributor Author

Squashed.

jehiah added a commit that referenced this pull request May 6, 2015
remove regexp for performance
@jehiah jehiah merged commit 0c1b556 into bitly:master May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants