volume: add option to limit compaction speed
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
@@ -72,8 +73,8 @@ func TestCompaction(t *testing.T) {
|
||||
t.Fatalf("volume creation: %v", err)
|
||||
}
|
||||
|
||||
beforeCommitFileCount := 1000
|
||||
afterCommitFileCount := 1000
|
||||
beforeCommitFileCount := 10000
|
||||
afterCommitFileCount := 10000
|
||||
|
||||
infos := make([]*needleInfo, beforeCommitFileCount+afterCommitFileCount)
|
||||
|
||||
@@ -81,7 +82,10 @@ func TestCompaction(t *testing.T) {
|
||||
doSomeWritesDeletes(i, v, t, infos)
|
||||
}
|
||||
|
||||
v.Compact(0)
|
||||
startTime := time.Now()
|
||||
v.Compact(0, 1024*1024)
|
||||
speed := float64(v.ContentSize()) / time.Now().Sub(startTime).Seconds()
|
||||
t.Logf("compaction speed: %.2f bytes/s", speed)
|
||||
|
||||
for i := 1; i <= afterCommitFileCount; i++ {
|
||||
doSomeWritesDeletes(i+beforeCommitFileCount, v, t, infos)
|
||||
|
||||
Reference in New Issue
Block a user