File: cookie_timing_test.go

package info (click to toggle)
golang-github-valyala-fasthttp 1%3A1.59.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,932 kB
  • sloc: makefile: 34
file content (35 lines) | stat: -rw-r--r-- 821 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package fasthttp

import (
	"testing"
)

func BenchmarkCookieParseMin(b *testing.B) {
	var c Cookie
	s := []byte("xxx=yyy")
	for i := 0; i < b.N; i++ {
		if err := c.ParseBytes(s); err != nil {
			b.Fatalf("unexpected error when parsing cookies: %v", err)
		}
	}
}

func BenchmarkCookieParseNoExpires(b *testing.B) {
	var c Cookie
	s := []byte("xxx=yyy; domain=foobar.com; path=/a/b")
	for i := 0; i < b.N; i++ {
		if err := c.ParseBytes(s); err != nil {
			b.Fatalf("unexpected error when parsing cookies: %v", err)
		}
	}
}

func BenchmarkCookieParseFull(b *testing.B) {
	var c Cookie
	s := []byte("xxx=yyy; expires=Tue, 10 Nov 2009 23:00:00 GMT; domain=foobar.com; path=/a/b")
	for i := 0; i < b.N; i++ {
		if err := c.ParseBytes(s); err != nil {
			b.Fatalf("unexpected error when parsing cookies: %v", err)
		}
	}
}