aboutsummaryrefslogtreecommitdiff
path: root/bencode/comparison_test.go
blob: 24ded8f21258a8cb2cdd02db67779fe87bbe8e0b (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package bencode

import (
	"bytes"
	"testing"

	alt1 "github.com/marksamman/bencode"
)

func BenchmarkMyStringDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		Decode([]byte("11:hello world"))
	}
}

func BenchmarkMyIntDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		Decode([]byte("i1234234e"))
	}
}

func BenchmarkMyListDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		Decode([]byte("l4:spam4:eggse"))
	}
}

func BenchmarkMyDictDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		Decode([]byte("d4:spam4:eggse"))
	}
}

func BenchmarkAlt1StringDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		alt1.Decode(bytes.NewBufferString("11:hello world"))
	}
}

func BenchmarkAlt1IntDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		alt1.Decode(bytes.NewBufferString("i1234234e"))
	}
}

func BenchmarkAlt1ListDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		alt1.Decode(bytes.NewBufferString("l4:spam4:eggse"))
	}
}

func BenchmarkAlt1DictDecode(b *testing.B) {
	for n := 0; n < b.N; n++ {
		alt1.Decode(bytes.NewBufferString("d4:spam4:eggse"))
	}
}