MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestCaptchaMemory

Function TestCaptchaMemory

internal/waf/captcha_test.go:15–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestCaptchaMemory(t *testing.T) {
16 if !testutils.IsSingleTesting() {
17 return
18 }
19
20 var stat1 = &runtime.MemStats{}
21 runtime.ReadMemStats(stat1)
22
23 var count = 5_000
24 var before = time.Now()
25
26 for i := 0; i < count; i++ {
27 var id = captcha.NewLen(6)
28 var writer = &bytes.Buffer{}
29 err := captcha.WriteImage(writer, id, 200, 100)
30 if err != nil {
31 t.Fatal(err)
32 }
33 captcha.VerifyString(id, "abc")
34 }
35
36 var stat2 = &runtime.MemStats{}
37 runtime.ReadMemStats(stat2)
38 t.Log((stat2.HeapInuse-stat1.HeapInuse)>>20, "MB", fmt.Sprintf("%.0f QPS", float64(count)/time.Since(before).Seconds()))
39}
40
41func BenchmarkCaptcha_VerifyCode_100_50(b *testing.B) {
42 runtime.GOMAXPROCS(4)

Callers

nothing calls this directly

Calls 3

IsSingleTestingFunction · 0.92
WriteImageMethod · 0.80
LogMethod · 0.80

Tested by

no test coverage detected