Codebase list golang-github-valyala-fasthttp / 5ec09c71-43d7-4e16-a9c0-c07700f5e59a/v1.41.0 cookie_timing_test.go
5ec09c71-43d7-4e16-a9c0-c07700f5e59a/v1.41.0

Tree @5ec09c71-43d7-4e16-a9c0-c07700f5e59a/v1.41.0 (Download .tar.gz)

cookie_timing_test.go @5ec09c71-43d7-4e16-a9c0-c07700f5e59a/v1.41.0raw · history · blame

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)
		}
	}
}