2017-02-01 06:18:52 +01:00
|
|
|
package memorybysubnet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
s "github.com/chihaya/chihaya/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
func createNew() s.PeerStore {
|
2017-05-04 02:49:20 +02:00
|
|
|
ps, err := New(Config{
|
2017-05-04 04:40:27 +02:00
|
|
|
ShardCount: 1024,
|
|
|
|
GarbageCollectionInterval: 10 * time.Minute,
|
2017-08-17 23:35:20 +02:00
|
|
|
PeerLifetime: 30 * time.Minute,
|
2017-05-04 04:40:27 +02:00
|
|
|
PreferredIPv4SubnetMaskBitsSet: 31,
|
|
|
|
PreferredIPv6SubnetMaskBitsSet: 64,
|
2017-05-04 02:49:20 +02:00
|
|
|
})
|
2017-02-01 06:18:52 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return ps
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPeerStore(t *testing.T) { s.TestPeerStore(t, createNew()) }
|
|
|
|
|
2017-08-24 12:45:17 +02:00
|
|
|
func BenchmarkNop(b *testing.B) { s.Nop(b, createNew()) }
|
2017-02-01 06:18:52 +01:00
|
|
|
func BenchmarkPut(b *testing.B) { s.Put(b, createNew()) }
|
|
|
|
func BenchmarkPut1k(b *testing.B) { s.Put1k(b, createNew()) }
|
|
|
|
func BenchmarkPut1kInfohash(b *testing.B) { s.Put1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkPut1kInfohash1k(b *testing.B) { s.Put1kInfohash1k(b, createNew()) }
|
|
|
|
func BenchmarkPutDelete(b *testing.B) { s.PutDelete(b, createNew()) }
|
|
|
|
func BenchmarkPutDelete1k(b *testing.B) { s.PutDelete1k(b, createNew()) }
|
|
|
|
func BenchmarkPutDelete1kInfohash(b *testing.B) { s.PutDelete1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkPutDelete1kInfohash1k(b *testing.B) { s.PutDelete1kInfohash1k(b, createNew()) }
|
|
|
|
func BenchmarkDeleteNonexist(b *testing.B) { s.DeleteNonexist(b, createNew()) }
|
|
|
|
func BenchmarkDeleteNonexist1k(b *testing.B) { s.DeleteNonexist1k(b, createNew()) }
|
|
|
|
func BenchmarkDeleteNonexist1kInfohash(b *testing.B) { s.DeleteNonexist1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkDeleteNonexist1kInfohash1k(b *testing.B) { s.DeleteNonexist1kInfohash1k(b, createNew()) }
|
|
|
|
func BenchmarkPutGradDelete(b *testing.B) { s.PutGradDelete(b, createNew()) }
|
|
|
|
func BenchmarkPutGradDelete1k(b *testing.B) { s.PutGradDelete1k(b, createNew()) }
|
|
|
|
func BenchmarkPutGradDelete1kInfohash(b *testing.B) { s.PutGradDelete1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkPutGradDelete1kInfohash1k(b *testing.B) { s.PutGradDelete1kInfohash1k(b, createNew()) }
|
|
|
|
func BenchmarkGradNonexist(b *testing.B) { s.GradNonexist(b, createNew()) }
|
|
|
|
func BenchmarkGradNonexist1k(b *testing.B) { s.GradNonexist1k(b, createNew()) }
|
|
|
|
func BenchmarkGradNonexist1kInfohash(b *testing.B) { s.GradNonexist1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkGradNonexist1kInfohash1k(b *testing.B) { s.GradNonexist1kInfohash1k(b, createNew()) }
|
|
|
|
func BenchmarkAnnounceLeecher(b *testing.B) { s.AnnounceLeecher(b, createNew()) }
|
|
|
|
func BenchmarkAnnounceLeecher1kInfohash(b *testing.B) { s.AnnounceLeecher1kInfohash(b, createNew()) }
|
|
|
|
func BenchmarkAnnounceSeeder(b *testing.B) { s.AnnounceSeeder(b, createNew()) }
|
|
|
|
func BenchmarkAnnounceSeeder1kInfohash(b *testing.B) { s.AnnounceSeeder1kInfohash(b, createNew()) }
|
2017-08-24 12:45:17 +02:00
|
|
|
func BenchmarkScrapeSwarm(b *testing.B) { s.ScrapeSwarm(b, createNew()) }
|
|
|
|
func BenchmarkScrapeSwarm1kInfohash(b *testing.B) { s.ScrapeSwarm1kInfohash(b, createNew()) }
|