From: Matt Joiner <anacrolix@gmail.com>
Date: Mon, 22 Jun 2015 09:43:22 +0000 (+1000)
Subject: Add benchmark for adding a torrent with a lot of pieces
X-Git-Tag: v1.0.0~1150
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d8cf0f1e349bdd62cd0c02200871380182eb09c3;p=btrtrc.git

Add benchmark for adding a torrent with a lot of pieces
---

diff --git a/client_test.go b/client_test.go
index cfdbd7eb..3cd1f0ec 100644
--- a/client_test.go
+++ b/client_test.go
@@ -388,3 +388,19 @@ func TestCompletedPieceWrongSize(t *testing.T) {
 	}
 	defer tt.Drop()
 }
+
+func BenchmarkAddLargeTorrent(b *testing.B) {
+	cfg := TestingConfig
+	cfg.DisableTCP = true
+	cfg.DisableUTP = true
+	cfg.ListenAddr = "redonk"
+	cl, _ := NewClient(&cfg)
+	defer cl.Close()
+	for range iter.N(b.N) {
+		t, err := cl.AddTorrentFromFile("testdata/bootstrap.dat.torrent")
+		if err != nil {
+			b.Fatal(err)
+		}
+		t.Drop()
+	}
+}
diff --git a/testdata/bootstrap.dat.torrent b/testdata/bootstrap.dat.torrent
new file mode 100644
index 00000000..e5cdeb7c
Binary files /dev/null and b/testdata/bootstrap.dat.torrent differ