Skip to content

Commit

Permalink
wrap wal module
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshi-099 committed Jan 4, 2024
1 parent f9240b4 commit 5d88a02
Show file tree
Hide file tree
Showing 12 changed files with 2,021 additions and 344 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
rotom.db
*.db
tmp
coverage.*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test-cover:
go tool cover -html=coverage.txt -o coverage.html

rm coverage.txt
rm *.db
rm -r tmp*

pprof:
go tool pprof -http=:18081 "http://localhost:6060/debug/pprof/profile?seconds=60"
Expand Down
25 changes: 11 additions & 14 deletions benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ const (
KB = 1 << (10 * (iota + 1))
MB
GB
TB
)

func convertSize(size int64) string {
switch {
case size >= TB:
return fmt.Sprintf("%.1fTB", float64(size)/TB)
case size >= GB:
return fmt.Sprintf("%.1fGB", float64(size)/GB)
case size >= MB:
Expand All @@ -41,12 +38,12 @@ func fileSize(filename string) string {
return convertSize(size)
}

func createDB() *rotom.Engine {
cfg := rotom.DefaultConfig
cfg.Logger = nil
cfg.Path = fmt.Sprintf("%d.db", time.Now().UnixNano())
func createDB() *rotom.DB {
options := rotom.DefaultOptions
options.Logger = nil
options.DirPath = fmt.Sprintf("%d", time.Now().UnixNano())

db, err := rotom.Open(cfg)
db, err := rotom.Open(options)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -81,7 +78,7 @@ func benchSet() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down Expand Up @@ -123,7 +120,7 @@ func benchSet8parallel() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down Expand Up @@ -154,7 +151,7 @@ func benchSetEx() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down Expand Up @@ -217,7 +214,7 @@ func benchHSet() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down Expand Up @@ -248,7 +245,7 @@ func benchLRPush() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down Expand Up @@ -310,7 +307,7 @@ func benchBitSet() {
fmt.Printf("99th: %.0f ns\n", td.Quantile(0.99))
// wait for sync
time.Sleep(time.Second)
fmt.Printf("db file size: %v\n", fileSize(db.Path))
fmt.Printf("db file size: %v\n", fileSize(db.DirPath))
fmt.Println()
}

Expand Down
Loading

0 comments on commit 5d88a02

Please sign in to comment.