diff options
| author | Felix Hanley <felix@userspace.com.au> | 2018-01-21 13:34:59 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2018-01-21 13:34:59 +0000 |
| commit | be4f4b36cc7fb46c70364d524d64c7188c1ae0f3 (patch) | |
| tree | bd3ea61d32c8892e14a27c843e965bd7048b78d0 /bencode/comparison_test.go | |
| parent | 25ec6208dd2617989f11d093092d47a00d6de25d (diff) | |
| download | dhtsearch-be4f4b36cc7fb46c70364d524d64c7188c1ae0f3.tar.gz dhtsearch-be4f4b36cc7fb46c70364d524d64c7188c1ae0f3.tar.bz2 | |
Use my own bencode implementation
Diffstat (limited to 'bencode/comparison_test.go')
| -rw-r--r-- | bencode/comparison_test.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/bencode/comparison_test.go b/bencode/comparison_test.go new file mode 100644 index 0000000..24ded8f --- /dev/null +++ b/bencode/comparison_test.go @@ -0,0 +1,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")) + } +} |
