Skip to content

Commit

Permalink
Use simpler imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Apr 19, 2022
1 parent 89c5f3d commit ba8aac5
Show file tree
Hide file tree
Showing 6 changed files with 556 additions and 556 deletions.
64 changes: 32 additions & 32 deletions bencode/bencode_marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import (
"bytes"
"testing"

bencode2 "github.com/IncSW/go-bencode"
bencode8 "github.com/anacrolix/torrent/bencode"
bencode7 "github.com/chihaya/chihaya/frontend/http/bencode"
bencode1 "github.com/cristalhq/bencode"
bencode16 "github.com/cuberat/go-bencode"
bencode11 "github.com/ehmry/go-bencode"
bencode6 "github.com/jackpal/bencode-go"
bencode15 "github.com/lajide/bencode"
bencode13 "github.com/lwch/bencode"
bencode5 "github.com/marksamman/bencode"
bencode4 "github.com/nabilanam/bencode/encoder"
bencode9 "github.com/owenliang/dht"
bencode12 "github.com/stints/bencode"
bencode10 "github.com/tumdum/bencoding"
bencode3 "github.com/zeebo/bencode"
IncSW "github.com/IncSW/go-bencode"
anacrolix "github.com/anacrolix/torrent/bencode"
chihaya "github.com/chihaya/chihaya/frontend/http/bencode"
cristalhq "github.com/cristalhq/bencode"
cuberat "github.com/cuberat/go-bencode"
ehmry "github.com/ehmry/go-bencode"
jackpal "github.com/jackpal/bencode-go"
lajide "github.com/lajide/bencode"
lwch "github.com/lwch/bencode"
marksamman "github.com/marksamman/bencode"
nabilanam "github.com/nabilanam/bencode/encoder"
owenliang "github.com/owenliang/dht"
stints "github.com/stints/bencode"
tumdum "github.com/tumdum/bencoding"
zeebo "github.com/zeebo/bencode"
)

var marshalBenchData = map[string]interface{}{
Expand All @@ -42,7 +42,7 @@ var marshalBenchData = map[string]interface{}{
func Benchmark_cristalhq_Marshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode1.Marshal(marshalBenchData)
_, err := cristalhq.Marshal(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -53,7 +53,7 @@ func Benchmark_cristalhq_MarshalTo(b *testing.B) {
dst := make([]byte, 0, 1<<12)
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode1.MarshalTo(dst, marshalBenchData)
_, err := cristalhq.MarshalTo(dst, marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -63,7 +63,7 @@ func Benchmark_cristalhq_MarshalTo(b *testing.B) {
func Benchmark_IncSW_Marshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode2.Marshal(marshalBenchData)
_, err := IncSW.Marshal(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -74,7 +74,7 @@ func Benchmark_IncSW_MarshalTo(b *testing.B) {
dst := make([]byte, 0, 1<<12)
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode2.MarshalTo(dst, marshalBenchData)
_, err := IncSW.MarshalTo(dst, marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -84,7 +84,7 @@ func Benchmark_IncSW_MarshalTo(b *testing.B) {
func Benchmark_Zeebo_Marshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode3.EncodeBytes(marshalBenchData)
_, err := zeebo.EncodeBytes(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -94,7 +94,7 @@ func Benchmark_Zeebo_Marshal(b *testing.B) {
func Benchmark_Marksamman_Marshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode5.Encode(marshalBenchData)
err := marksamman.Encode(marshalBenchData)
if err == nil {
b.Fatal("got nil")
}
Expand All @@ -105,7 +105,7 @@ func Benchmark_Anacrolix_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode8.NewEncoder(w).Encode(marshalBenchData)
err := anacrolix.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -116,7 +116,7 @@ func Benchmark_Nabilanam_Marshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
res := bencode4.New(marshalBenchData).Encode()
res := nabilanam.New(marshalBenchData).Encode()
if res != "" && b.N%3 == 66666 {
b.Fatal("empty")
}
Expand All @@ -128,7 +128,7 @@ func Benchmark_Jackpal_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode6.Marshal(w, marshalBenchData)
err := jackpal.Marshal(w, marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -140,7 +140,7 @@ func Benchmark_Chihaya_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode7.NewEncoder(w).Encode(marshalBenchData)
err := chihaya.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -151,7 +151,7 @@ func Benchmark_Owenliang_Marshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode9.Encode(marshalBenchData)
_, err := owenliang.Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -163,7 +163,7 @@ func Benchmark_Tumdum_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode10.NewEncoder(w).Encode(marshalBenchData)
err := tumdum.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -175,7 +175,7 @@ func Benchmark_Ehmry_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode11.NewEncoder(w).Encode(marshalBenchData)
err := ehmry.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -186,7 +186,7 @@ func Benchmark_Stints_Marshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
d := bencode12.NewEncoder().Encode(marshalBenchData)
d := stints.NewEncoder().Encode(marshalBenchData)
if d == nil {
b.Fatal("is nil")
}
Expand All @@ -198,7 +198,7 @@ func Benchmark_Lwch_Marshal(b *testing.B) {
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode13.NewEncoder(w).Encode(marshalBenchData)
err := lwch.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -210,7 +210,7 @@ func Benchmark_Lajide_Marshal(b *testing.B) {
buf := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode15.NewEncoder(buf).Encode(marshalBenchData)
err := lajide.NewEncoder(buf).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -222,7 +222,7 @@ func Benchmark_Cuberat_Marshal(b *testing.B) {
buf := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode16.NewEncoder(buf).Encode(marshalBenchData)
err := cuberat.NewEncoder(buf).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand Down
58 changes: 29 additions & 29 deletions bencode/bencode_unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import (
"io"
"testing"

bencode2 "github.com/IncSW/go-bencode"
bencode8 "github.com/anacrolix/torrent/bencode"
bencode7 "github.com/chihaya/chihaya/frontend/http/bencode"
bencode1 "github.com/cristalhq/bencode"
bencode16 "github.com/cuberat/go-bencode"
bencode11 "github.com/ehmry/go-bencode"
bencode6 "github.com/jackpal/bencode-go"
bencode15 "github.com/lajide/bencode"
bencode13 "github.com/lwch/bencode"
bencode5 "github.com/marksamman/bencode"
bencode4 "github.com/nabilanam/bencode/decoder"
bencode9 "github.com/owenliang/dht"
bencode10 "github.com/tumdum/bencoding"
bencode3 "github.com/zeebo/bencode"
IncSW "github.com/IncSW/go-bencode"
anacrolix "github.com/anacrolix/torrent/bencode"
chihaya "github.com/chihaya/chihaya/frontend/http/bencode"
cristalhq "github.com/cristalhq/bencode"
cuberat "github.com/cuberat/go-bencode"
ehmry "github.com/ehmry/go-bencode"
jackpal "github.com/jackpal/bencode-go"
lajide "github.com/lajide/bencode"
lwch "github.com/lwch/bencode"
marksamman "github.com/marksamman/bencode"
nabilanam "github.com/nabilanam/bencode/decoder"
owenliang "github.com/owenliang/dht"
tumdum "github.com/tumdum/bencoding"
zeebo "github.com/zeebo/bencode"
)

var unmarshalBenchData = []byte("d4:infod6:lengthi170917888e12:piece lengthi262144e4:name30:debian-8.8.0-arm64-netinst.isoe8:announce38:udp://tracker.publicbt.com:80/announce13:announce-listll38:udp://tracker.publicbt.com:80/announceel44:udp://tracker.openbittorrent.com:80/announceee7:comment33:Debian CD from cdimage.debian.orge")
Expand All @@ -27,7 +27,7 @@ func Benchmark_cristalhq_Unmarshal(b *testing.B) {
var res interface{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode1.NewDecodeBytes(unmarshalBenchData).Decode(&res)
err := cristalhq.NewDecodeBytes(unmarshalBenchData).Decode(&res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -42,7 +42,7 @@ func Benchmark_cristalhq_UnmarshalReader(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
r := bytes.NewReader(unmarshalBenchData)
err := bencode1.NewDecoder(r).Decode(&res)
err := cristalhq.NewDecoder(r).Decode(&res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -55,7 +55,7 @@ func Benchmark_cristalhq_UnmarshalReader(b *testing.B) {
func Benchmark_IncSW_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, err := bencode2.Unmarshal(unmarshalBenchData)
_, err := IncSW.Unmarshal(unmarshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -66,7 +66,7 @@ func Benchmark_ZeeboBencode_Unmarshal(b *testing.B) {
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode3.DecodeBytes(unmarshalBenchData, &res)
err := zeebo.DecodeBytes(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -79,7 +79,7 @@ func Benchmark_ZeeboBencode_Unmarshal(b *testing.B) {
func Benchmark_NabilanamBencode_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
res := bencode4.New(unmarshalBenchData).Decode()
res := nabilanam.New(unmarshalBenchData).Decode()
if res == nil {
b.Fatal("is nil")
}
Expand All @@ -90,7 +90,7 @@ func Benchmark_MarksammanBencode_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
r := bytes.NewReader(unmarshalBenchData)
_, err := bencode5.Decode(r)
_, err := marksamman.Decode(r)
if err != nil {
b.Fatal(err)
}
Expand All @@ -102,7 +102,7 @@ func Benchmark_JackpalBencode_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
r := bytes.NewReader(unmarshalBenchData)
_, err := bencode6.Decode(r)
_, err := jackpal.Decode(r)
if err != nil && err != io.EOF {
b.Fatal(err)
}
Expand All @@ -113,7 +113,7 @@ func Benchmark_ChihayaBencode_Unmarshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
bencode7.Unmarshal(unmarshalBenchData)
chihaya.Unmarshal(unmarshalBenchData)
}
}

Expand All @@ -122,7 +122,7 @@ func Benchmark_AnacrolixTorrent_Unmarshal(b *testing.B) {
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode8.Unmarshal(unmarshalBenchData, &res)
err := anacrolix.Unmarshal(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -135,7 +135,7 @@ func Benchmark_AnacrolixTorrent_Unmarshal(b *testing.B) {
func Benchmark_OwenliangDht_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
res, err := bencode9.Decode(unmarshalBenchData)
res, err := owenliang.Decode(unmarshalBenchData)
if err != nil {
b.Fatal(err)
}
Expand All @@ -150,7 +150,7 @@ func Benchmark_TumdumBencoding_Unmarshal(b *testing.B) {
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode10.Unmarshal(unmarshalBenchData, &res)
err := tumdum.Unmarshal(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -165,7 +165,7 @@ func Benchmark_EhmryGoBencode_Unmarshal(b *testing.B) {
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode11.Unmarshal(unmarshalBenchData, &res)
err := ehmry.Unmarshal(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -184,7 +184,7 @@ func Benchmark_LwchBencode_Unmarshal(b *testing.B) {
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := bencode13.Decode(unmarshalBenchData, &res)
err := lwch.Decode(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
Expand All @@ -203,7 +203,7 @@ func Benchmark_LajideBencode_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
buf := bytes.NewBuffer(unmarshalBenchData)
res, err := bencode15.NewDecoder(buf).Decode()
res, err := lajide.NewDecoder(buf).Decode()
if err != nil && err != io.EOF {
b.Fatal(err)
}
Expand All @@ -218,7 +218,7 @@ func Benchmark_CuberatGoBencode_Unmarshal(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
buf := bytes.NewBuffer(unmarshalBenchData)
res, err := bencode16.NewDecoder(buf).Decode()
res, err := cuberat.NewDecoder(buf).Decode()
if err != nil && err != io.EOF {
b.Fatal(err)
}
Expand Down
Loading

0 comments on commit ba8aac5

Please sign in to comment.