mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Express binCount using integer operations.
No need to bring a float64 into this.
This commit is contained in:
parent
70974640ab
commit
b058b10a94
1 changed files with 3 additions and 3 deletions
|
@ -8,7 +8,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -276,9 +275,10 @@ func (m *Metrics) printMetrics() {
|
||||||
m.logger.Println("snowflake-ips-nat-unknown", m.loadAndZero("proxy-nat-unknown"))
|
m.logger.Println("snowflake-ips-nat-unknown", m.loadAndZero("proxy-nat-unknown"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rounds up a count to the nearest multiple of 8.
|
// binCount rounds count up to the next multiple of 8. Returns 0 on integer
|
||||||
|
// overflow.
|
||||||
func binCount(count uint64) uint64 {
|
func binCount(count uint64) uint64 {
|
||||||
return uint64((math.Ceil(float64(count) / 8)) * 8)
|
return (count + 7) / 8 * 8
|
||||||
}
|
}
|
||||||
|
|
||||||
type PromMetrics struct {
|
type PromMetrics struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue