MCPcopy Create free account
hub / github.com/zalando/skipper / BenchmarkRandomAlgorithm

Function BenchmarkRandomAlgorithm

loadbalancer/algorithm_test.go:515–553  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

513}
514
515func BenchmarkRandomAlgorithm(b *testing.B) {
516 N := 10
517 eps := make([]string, N)
518 j := 0
519 k := 0
520 for i := range N {
521 j++
522 if j > 255 {
523 k++
524 j = 0
525 }
526 eps[i] = fmt.Sprintf("10.0.%d.%d", k, j)
527 }
528 if k > 255 {
529 b.Fatalf("Failed to benchmark: k > 255, k=%d", k)
530 }
531
532 alg := newRandom(eps)
533
534 lbeps := make([]routing.LBEndpoint, len(eps))
535 for i := range len(eps) {
536 lbe := routing.LBEndpoint{
537 Scheme: "http",
538 Host: eps[i],
539 Metrics: nil,
540 }
541 lbeps[i] = lbe
542 }
543
544 lbc := &routing.LBContext{
545 LBEndpoints: lbeps,
546 }
547
548 b.ResetTimer()
549
550 for n := 0; n < b.N; n++ {
551 alg.Apply(lbc)
552 }
553}

Callers

nothing calls this directly

Calls 2

newRandomFunction · 0.85
ApplyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…