summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/throttled/throttled.v1/memstats_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-09-23 10:17:51 -0400
committerGitHub <noreply@github.com>2016-09-23 10:17:51 -0400
commit2ca0e8f9a0f9863555a26e984cde15efff9ef8f8 (patch)
treedaae1ee67b14a3d0a84424f2a304885d9e75ce2b /vendor/gopkg.in/throttled/throttled.v1/memstats_test.go
parent6d62d65b2dc85855aabea036cbd44f6059e19d13 (diff)
downloadchat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.tar.gz
chat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.tar.bz2
chat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.zip
Updating golang dependancies (#4075)
Diffstat (limited to 'vendor/gopkg.in/throttled/throttled.v1/memstats_test.go')
-rw-r--r--vendor/gopkg.in/throttled/throttled.v1/memstats_test.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/gopkg.in/throttled/throttled.v1/memstats_test.go b/vendor/gopkg.in/throttled/throttled.v1/memstats_test.go
deleted file mode 100644
index 2b8faa721..000000000
--- a/vendor/gopkg.in/throttled/throttled.v1/memstats_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package throttled
-
-import (
- "net/http"
- "runtime"
- "testing"
- "time"
-
- "github.com/PuerkitoBio/boom/commands"
-)
-
-func TestMemStats(t *testing.T) {
- if testing.Short() {
- t.Skip()
- }
- cases := []struct {
- n int
- c int
- gc uint32
- total uint64
- rate time.Duration
- }{
- 0: {1000, 10, 3, 0, 0},
- 1: {200, 10, 0, 600000, 0},
- 2: {500, 10, 2, 555555, 10 * time.Millisecond},
- }
- for i, c := range cases {
- // Setup the stats handler
- st := &stats{}
- // Create the throttler
- limit := MemThresholds(&runtime.MemStats{NumGC: c.gc, TotalAlloc: c.total})
- th := MemStats(limit, c.rate)
- th.DeniedHandler = http.HandlerFunc(st.DeniedHTTP)
- // Run the test
- b := commands.Boom{
- Req: &commands.ReqOpts{},
- N: c.n,
- C: c.c,
- Output: "quiet",
- }
- rpts := runTest(th.Throttle(st), b)
- // Assert results
- assertStats(t, i, st, rpts)
- assertMem(t, i, limit)
- }
-}
-
-func assertMem(t *testing.T, ix int, limit *runtime.MemStats) {
- var mem runtime.MemStats
- runtime.ReadMemStats(&mem)
- if mem.NumGC < limit.NumGC {
- t.Errorf("%d: expected gc to be at least %d, got %d", ix, limit.NumGC, mem.NumGC)
- }
- if mem.TotalAlloc < limit.TotalAlloc {
- t.Errorf("%d: expected total alloc to be at least %dKb, got %dKb", ix, limit.TotalAlloc/1024, mem.TotalAlloc/1024)
- }
-}
-
-func BenchmarkReadMemStats(b *testing.B) {
- var mem runtime.MemStats
- for i := 0; i < b.N; i++ {
- runtime.ReadMemStats(&mem)
- }
-}