Get benchmarks working
This commit is contained in:
parent
afea28091f
commit
855144212c
|
@ -98,6 +98,10 @@ type piece struct {
|
|||
}
|
||||
|
||||
func (p2 piece) getBlob() *sqlite.Blob {
|
||||
rowid, err := rowidForBlob(p2.conn, p2.name, p2.length)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if *p2.blob != nil {
|
||||
err := (*p2.blob).Close()
|
||||
if err != nil {
|
||||
|
@ -105,10 +109,6 @@ func (p2 piece) getBlob() *sqlite.Blob {
|
|||
}
|
||||
*p2.blob = nil
|
||||
}
|
||||
rowid, err := rowidForBlob(p2.conn, p2.name, p2.length)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*p2.blob, err = p2.conn.OpenBlob("main", "blob", "data", rowid, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -144,7 +144,7 @@ func (p2 piece) MarkComplete() error {
|
|||
}
|
||||
|
||||
func (p2 piece) MarkNotComplete() error {
|
||||
panic("implement me")
|
||||
return sqlitex.Exec(p2.conn, "update blob set verified=false where name=?", nil, p2.name)
|
||||
}
|
||||
|
||||
func (p2 piece) Completion() (ret storage.Completion) {
|
||||
|
|
|
@ -76,21 +76,34 @@ func BenchmarkMarkComplete(b *testing.B) {
|
|||
b.Run(fmt.Sprintf("BatchWrites=%v", batchWrites), func(b *testing.B) {
|
||||
dbPath := filepath.Join(b.TempDir(), "storage.db")
|
||||
//b.Logf("storage db path: %q", dbPath)
|
||||
ci, err := NewPiecesStorage(NewPiecesStorageOpts{
|
||||
NewPoolOpts: NewPoolOpts{
|
||||
Path: dbPath,
|
||||
Capacity: 4*pieceSize - 1,
|
||||
NoConcurrentBlobReads: false,
|
||||
PageSize: 1 << 14,
|
||||
Memory: memory,
|
||||
},
|
||||
ProvOpts: func(opts *ProviderOpts) {
|
||||
opts.BatchWrites = batchWrites
|
||||
},
|
||||
newPoolOpts := NewPoolOpts{
|
||||
Path: dbPath,
|
||||
Capacity: 4*pieceSize - 1,
|
||||
NoConcurrentBlobReads: false,
|
||||
PageSize: 1 << 14,
|
||||
Memory: memory,
|
||||
}
|
||||
provOpts := func(opts *ProviderOpts) {
|
||||
opts.BatchWrites = batchWrites
|
||||
}
|
||||
b.Run("SqlitePieceStorage", func(b *testing.B) {
|
||||
ci, err := NewPiecesStorage(NewPiecesStorageOpts{
|
||||
NewPoolOpts: newPoolOpts,
|
||||
ProvOpts: provOpts,
|
||||
})
|
||||
c.Assert(err, qt.IsNil)
|
||||
defer ci.Close()
|
||||
test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, test_storage.DefaultNumPieces, capacity)
|
||||
})
|
||||
b.Run("SqliteDirect", func(b *testing.B) {
|
||||
ci, err := NewDirectStorage(NewDirectStorageOpts{
|
||||
NewPoolOpts: newPoolOpts,
|
||||
ProvOpts: provOpts,
|
||||
})
|
||||
c.Assert(err, qt.IsNil)
|
||||
defer ci.Close()
|
||||
test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, test_storage.DefaultNumPieces, capacity)
|
||||
})
|
||||
c.Assert(err, qt.IsNil)
|
||||
defer ci.Close()
|
||||
test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, test_storage.DefaultNumPieces, capacity)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue