mirror of
https://github.com/caddyserver/caddy.git
synced 2026-11-19 14:29:41 +00:00
Merge 8ac3351594 into 7ce9f08237
This commit is contained in:
commit
f2cc821936
2 changed files with 19 additions and 3 deletions
18
modules/caddyhttp/reverseproxy/hash_bench_test.go
Normal file
18
modules/caddyhttp/reverseproxy/hash_bench_test.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package reverseproxy
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkHostByHashing(b *testing.B) {
|
||||
pool := make(UpstreamPool, 0, 8)
|
||||
for i := 0; i < 8; i++ {
|
||||
pool = append(pool, &Upstream{Host: new(Host), Dial: "10.0.0." + strconv.Itoa(i) + ":8080"})
|
||||
}
|
||||
const key = "192.168.1.100"
|
||||
b.ReportAllocs()
|
||||
for b.Loop() {
|
||||
_ = hostByHashing(pool, key)
|
||||
}
|
||||
}
|
||||
|
|
@ -868,9 +868,7 @@ func hostByHashing(pool []*Upstream, s string) *Upstream {
|
|||
|
||||
// hash calculates a fast hash based on s.
|
||||
func hash(s string) uint64 {
|
||||
h := xxhash.New()
|
||||
_, _ = h.Write([]byte(s))
|
||||
return h.Sum64()
|
||||
return xxhash.Sum64String(s)
|
||||
}
|
||||
|
||||
func loadFallbackPolicy(d *caddyfile.Dispenser) (json.RawMessage, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue