-
Notifications
You must be signed in to change notification settings - Fork 188
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
Provide a IntCounter and IntGauge #149
Comments
prometheus-go implements similar optimizations, but leaving a nicer interface (transparent to users): prometheus/client_golang@ae69392 |
cool, but we should support math.Trunc, and do a benchmark to compare Trunc + Int Atomic and Float Atomic. |
yes. I will do a benchmark. If the performance impact of math.trunc is minimal, I prefer this way. |
According to the benchmark, adding a trunc check (and uses float as interface) will slow down about 20%~30% compared to AtomicInt: Mac:
Linux:
However it is still nearly 30%~50% faster than the AtomicFloat. In addition, the f64 is as slow as the RwLock implementation (with is used as a replacement without nightly). |
how about using https://github.com/prometheus/client_golang/pull/367/files#diff-4eafde073feb6e8d8a2aefcc731b59c4R91 instead of math.Trunc? |
According to the rust book,
I guess it is equal to |
Time consumption of these two are exactly the same. |
Mostly, we use the integer for counter and gauge, so it is more efficient to use atomic int64 directly than float64.
The text was updated successfully, but these errors were encountered: