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

Export in-memory counter for external use #39

Merged
merged 1 commit into from
Jul 25, 2024
Merged

Export in-memory counter for external use #39

merged 1 commit into from
Jul 25, 2024

Conversation

VojtechVitek
Copy link
Contributor

httprate.NewLocalLimitCounter(windowLength)

The idea is that other backends (e.g. https://github.com/go-chi/httprate-redis) could fall-back to the in-memory counter.

httprate.NewLocalLimitCounter(windowLength)
Copy link

Benchmark Results

goos: linux
goarch: amd64
pkg: github.com/go-chi/httprate
cpu: AMD EPYC 7763 64-Core Processor                
               │ master.txt  │               pr.txt               │
               │   sec/op    │   sec/op     vs base               │
LocalCounter-4   19.60m ± 1%   19.72m ± 1%  +0.61% (p=0.009 n=10)

               │  master.txt  │             pr.txt             │
               │     B/op     │     B/op      vs base          │
LocalCounter-4   2.833Mi ± 0%   2.831Mi ± 0%  ~ (p=0.481 n=10)

               │ master.txt  │            pr.txt             │
               │  allocs/op  │  allocs/op   vs base          │
LocalCounter-4   121.5k ± 0%   121.4k ± 0%  ~ (p=0.481 n=10)

@VojtechVitek VojtechVitek merged commit 9e50ad6 into master Jul 25, 2024
3 checks passed
@VojtechVitek VojtechVitek deleted the 1IrucoQ0 branch July 25, 2024 17:55
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.

1 participant