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

Fix benchmark to reuse parsers #11

Merged
merged 2 commits into from
Jun 26, 2018
Merged

Conversation

RReverser
Copy link
Contributor

@RReverser RReverser commented Jun 22, 2018

Initialisation of parser might be quite expensive, and, obviously, in real use-case it's meant to be reused, so this commit moves parser inits into lazy_static! block for more fair comparison.

Before:

test bench_stabilizer ... bench:          30 ns/iter (+/- 10)
test smoke_uap        ... bench: 229,254,862 ns/iter (+/- 14,099,776)
test smoke_woothee    ... bench:       8,678 ns/iter (+/- 1,500)

After:

test bench_stabilizer ... bench:          24 ns/iter (+/- 2)
test smoke_uap        ... bench:     352,355 ns/iter (+/- 68,453)
test smoke_woothee    ... bench:       8,657 ns/iter (+/- 1,178)

Woothee is still much faster and hasn't changed numbers too much, but UAP numbers became ~650x better as they now measure just UA parsing and not loading the database.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Initialisation of parser might be quite expensive, and, obviously, in real use-case it's meant to be reused, so this commit moves parser inits into lazy_static! block for more fair comparison.

Before:
```
running 3 tests
test bench_stabilizer ... bench:          30 ns/iter (+/- 10)
test smoke_uap        ... bench: 229,254,862 ns/iter (+/- 14,099,776)
test smoke_woothee    ... bench:       8,678 ns/iter (+/- 1,500)
```

After:
```
test bench_stabilizer ... bench:          24 ns/iter (+/- 2)
test smoke_uap        ... bench:     352,355 ns/iter (+/- 68,453)
test smoke_woothee    ... bench:       8,657 ns/iter (+/- 1,178)
```

Woothee is still much faster and hasn't changed numbers too much, but UAP numbers became ~650x better as they now measure just UA parsing and not loading the database.
Make sure that result values are not optimised away.
@hhatto
Copy link
Member

hhatto commented Jun 26, 2018

@RReverser

Thank you for contribution.
LGTM 👍

@hhatto hhatto merged commit 7af71c8 into woothee:master Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants