github.com/anacrolix/torrent@v1.61.0/storage/mark-complete_test.go (about) 1 package storage_test 2 3 import ( 4 "testing" 5 6 g "github.com/anacrolix/generics" 7 8 "github.com/anacrolix/torrent/storage" 9 test_storage "github.com/anacrolix/torrent/storage/test" 10 ) 11 12 func BenchmarkMarkComplete(b *testing.B) { 13 bench := func(b *testing.B, ci storage.ClientImpl) { 14 test_storage.BenchmarkPieceMarkComplete( 15 b, ci, test_storage.DefaultPieceSize, test_storage.DefaultNumPieces, 0) 16 } 17 b.Run("File", func(b *testing.B) { 18 ci := storage.NewFileOpts(storage.NewFileClientOpts{ 19 ClientBaseDir: b.TempDir(), 20 // TODO: Is the benchmark finding a bug? 21 UsePartFiles: g.Some(false), 22 }) 23 //ci := storage.NewFile(b.TempDir()) 24 b.Cleanup(func() { ci.Close() }) 25 bench(b, ci) 26 }) 27 b.Run("Mmap", func(b *testing.B) { 28 ci := storage.NewMMap(b.TempDir()) 29 b.Cleanup(func() { ci.Close() }) 30 bench(b, ci) 31 }) 32 b.Run("BoltDb", func(b *testing.B) { 33 ci := storage.NewBoltDB(b.TempDir()) 34 b.Cleanup(func() { ci.Close() }) 35 bench(b, ci) 36 }) 37 }