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

mock: add Counters, Gauges and Timers methods to get a map of all stats #90

Merged
merged 2 commits into from
Jun 18, 2020

Conversation

charlievieth
Copy link
Contributor

@charlievieth charlievieth commented Mar 6, 2020

Add Counters(), Gauges() and Timers() methods to stats/mock that return maps
of all the currently stored counters/gauges/timers. This makes it easier to identify
extraneous stats in tests.

This PR also increases test coverage and improves Sink performance when called
in parallel.

$ go test -covermode=atomic
PASS
coverage: 97.5% of statements
ok  	github.com/lyft/gostats/mock	0.016s
benchmark                             old ns/op     new ns/op     delta
BenchmarkFlushCounter-12              50.4          51.9          +2.98%
BenchmarkFlushCounter_Parallel-12     36.5          10.5          -71.23%
BenchmarkFlushTimer-12                52.1          49.8          -4.41%
BenchmarkFlushTimer_Parallel-12       42.0          13.5          -67.86%

benchmark                             old allocs     new allocs     delta
BenchmarkFlushCounter-12              0              0              +0.00%
BenchmarkFlushCounter_Parallel-12     0              0              +0.00%
BenchmarkFlushTimer-12                0              0              +0.00%
BenchmarkFlushTimer_Parallel-12       0              0              +0.00%

benchmark                             old bytes     new bytes     delta
BenchmarkFlushCounter-12              0             0             +0.00%
BenchmarkFlushCounter_Parallel-12     0             0             +0.00%
BenchmarkFlushTimer-12                0             0             +0.00%
BenchmarkFlushTimer_Parallel-12       0             0             +0.00%

Charlie Vieth added 2 commits June 16, 2020 13:37
This improves Sink performance when called in parallel.

```
benchmark                             old ns/op     new ns/op     delta
BenchmarkFlushCounter-12              50.4          51.9          +2.98%
BenchmarkFlushCounter_Parallel-12     36.5          10.5          -71.23%
BenchmarkFlushTimer-12                52.1          49.8          -4.41%
BenchmarkFlushTimer_Parallel-12       42.0          13.5          -67.86%

benchmark                             old allocs     new allocs     delta
BenchmarkFlushCounter-12              0              0              +0.00%
BenchmarkFlushCounter_Parallel-12     0              0              +0.00%
BenchmarkFlushTimer-12                0              0              +0.00%
BenchmarkFlushTimer_Parallel-12       0              0              +0.00%

benchmark                             old bytes     new bytes     delta
BenchmarkFlushCounter-12              0             0             +0.00%
BenchmarkFlushCounter_Parallel-12     0             0             +0.00%
BenchmarkFlushTimer-12                0             0             +0.00%
BenchmarkFlushTimer_Parallel-12       0             0             +0.00%
```
@charlievieth charlievieth changed the title mock: Sink replace mutex with atomic.Value mock: add Counters, Gauges and Timers methods to get a map of all stats Jun 18, 2020
@charlievieth charlievieth merged commit f9add79 into master Jun 18, 2020
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.

2 participants