(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestUserAgentParser_Memory(t *testing.T) { |
| 32 | var stat1 = &runtime.MemStats{} |
| 33 | runtime.ReadMemStats(stat1) |
| 34 | |
| 35 | var parser = stats.NewUserAgentParser() |
| 36 | |
| 37 | for i := 0; i < 1_000_000; i++ { |
| 38 | parser.Parse("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Test/" + types.String(rands.Int(0, 1_000_000))) |
| 39 | } |
| 40 | |
| 41 | runtime.GC() |
| 42 | debug.FreeOSMemory() |
| 43 | |
| 44 | var stat2 = &runtime.MemStats{} |
| 45 | runtime.ReadMemStats(stat2) |
| 46 | |
| 47 | t.Log("max cache items:", parser.MaxCacheItems()) |
| 48 | t.Log("cache:", parser.Len(), "usage:", (stat2.HeapInuse-stat1.HeapInuse)>>20, "MB") |
| 49 | } |
| 50 | |
| 51 | func TestNewUserAgentParser_GC(t *testing.T) { |
| 52 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected