aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-11-18 16:49:08 -0800
committerChris Lu <chris.lu@gmail.com>2018-11-18 16:49:08 -0800
commitf1db22d48bf71ef1fdfb41ebf7d08d8d7b0967a2 (patch)
treee4488af8d5b7ec7e2fe9fa490cacc2ea78522cf3
parent4fcfc9410fd407165d7bb1c047bcd21e5b2b7dde (diff)
downloadseaweedfs-f1db22d48bf71ef1fdfb41ebf7d08d8d7b0967a2.tar.xz
seaweedfs-f1db22d48bf71ef1fdfb41ebf7d08d8d7b0967a2.zip
add benchmark test for merging intervals
-rw-r--r--weed/filer2/filechunks_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/weed/filer2/filechunks_test.go b/weed/filer2/filechunks_test.go
index 1b124981f..292b7fc25 100644
--- a/weed/filer2/filechunks_test.go
+++ b/weed/filer2/filechunks_test.go
@@ -317,3 +317,32 @@ func TestChunksReading(t *testing.T) {
}
}
+
+func BenchmarkNonOverlappingVisibleIntervals(b *testing.B) {
+
+ chunks := []*filer_pb.FileChunk{
+ {Offset: 0, Size: 2097152, FileId: "7,0294cbb9892b", Mtime: 123},
+ {Offset: 0, Size: 3145728, FileId: "3,029565bf3092", Mtime: 130},
+ {Offset: 2097152, Size: 3145728, FileId: "6,029632f47ae2", Mtime: 140},
+ {Offset: 5242880, Size: 3145728, FileId: "2,029734c5aa10", Mtime: 150},
+ {Offset: 8388608, Size: 3145728, FileId: "5,02982f80de50", Mtime: 160},
+ {Offset: 11534336, Size: 2842193, FileId: "7,0299ad723803", Mtime: 170},
+ }
+
+ k := 1024
+
+ for n := 0; n < k; n++ {
+ chunks = append(chunks, &filer_pb.FileChunk{
+ Offset: int64(n*100), Size: 100, FileId: "7,0294cbb9892b", Mtime: int64(n),
+ })
+ chunks = append(chunks, &filer_pb.FileChunk{
+ Offset: int64(n*50), Size: 100, FileId: "7,0294cbb9892b", Mtime: int64(n+k),
+ })
+ }
+
+ // run the Fib function b.N times
+ for n := 0; n < b.N; n++ {
+ intervals := nonOverlappingVisibleIntervals(chunks)
+ cleanupIntervals(intervals)
+ }
+}