Skip to content

Commit

Permalink
add mysql result
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Jan 8, 2025
1 parent 1ac68db commit 970a161
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions stores/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
isql "go.sia.tech/renterd/internal/sql"
"go.sia.tech/renterd/object"
"go.sia.tech/renterd/stores/sql"
"go.sia.tech/renterd/stores/sql/mysql"
"go.sia.tech/renterd/stores/sql/sqlite"
"go.uber.org/zap"

Expand Down Expand Up @@ -123,7 +124,8 @@ func BenchmarkPrunableContractRoots(b *testing.B) {
// containing 100 TiB worth of slabs of which 50% are prunable in batches that
// reflect our batchsize in production.
//
// 2.3 TB/s | M2 Pro | fd751630
// 2.3 TB/s | M2 Pro | fd751630 | SQLite
// 0.8 TB/s | M2 Pro | fd751630 | MySQL
func BenchmarkPruneSlabs(b *testing.B) {
// define parameters
totalShardsPerSlab := 30 // shards per slab
Expand All @@ -134,7 +136,7 @@ func BenchmarkPruneSlabs(b *testing.B) {
}

// prepare database
db, err := newTestDB(context.Background(), b.TempDir())
db, err := newTestMysqlDB(context.Background())
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -339,3 +341,29 @@ func newTestDB(ctx context.Context, dir string) (*sqlite.MainDatabase, error) {

return dbMain, nil
}

func newTestMysqlDB(ctx context.Context) (*mysql.MainDatabase, error) {
db, err := mysql.Open("root", "test", "localhost:3306", "")
if err != nil {
return nil, err
}

dbName := fmt.Sprintf("bench_%d", time.Now().UnixNano())
if _, err := db.Exec(fmt.Sprintf("CREATE DATABASE %s", dbName)); err != nil {
return nil, err
}
if _, err := db.Exec(fmt.Sprintf("USE %s", dbName)); err != nil {
return nil, err
}
dbMain, err := mysql.NewMainDatabase(db, zap.NewNop(), 100*time.Millisecond, 100*time.Millisecond, "")
if err != nil {
return nil, err
}

err = dbMain.Migrate(ctx)
if err != nil {
return nil, err
}

return dbMain, nil
}

0 comments on commit 970a161

Please sign in to comment.