File: args_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 (30 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (4)
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
package fasthttp

import (
	"bytes"
	"testing"
)

func BenchmarkArgsParse(b *testing.B) {
	s := []byte("foo=bar&baz=qqq&aaaaa=bbbb")
	b.RunParallel(func(pb *testing.PB) {
		var a Args
		for pb.Next() {
			a.ParseBytes(s)
		}
	})
}

func BenchmarkArgsPeek(b *testing.B) {
	value := []byte("foobarbaz1234")
	key := "foobarbaz"
	b.RunParallel(func(pb *testing.PB) {
		var a Args
		a.SetBytesV(key, value)
		for pb.Next() {
			if !bytes.Equal(a.Peek(key), value) {
				b.Fatalf("unexpected arg value %q. Expecting %q", a.Peek(key), value)
			}
		}
	})
}