forked from bogdanovich/siberite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update README.md - Add some test benchmarks
- Loading branch information
Anton Bogdanovich
committed
Nov 10, 2015
1 parent
5b4fd08
commit 24b67b4
Showing
9 changed files
with
456 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
package cgroup | ||
|
||
import ( | ||
"crypto/rand" | ||
"testing" | ||
) | ||
|
||
func Benchmark_CGQueue_Enqueue_1_Byte(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1) | ||
rand.Read(value) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.Enqueue(value) | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_Enqueue_128_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 128) | ||
rand.Read(value) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
} | ||
|
||
func Benchmark_CGQueue_Enqueue_1024_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1024) | ||
rand.Read(value) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
} | ||
|
||
func Benchmark_CGQueue_Enqueue_10240_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 10240) | ||
rand.Read(value) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.Enqueue(value) | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_GetNext_1_Byte(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1) | ||
rand.Read(value) | ||
for i := 0; i < 500000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_GetNext_128_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 128) | ||
rand.Read(value) | ||
for i := 0; i < 500000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_GetNext_1024_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1024) | ||
rand.Read(value) | ||
for i := 0; i < 200000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_GetNext_10240_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 10240) | ||
rand.Read(value) | ||
for i := 0; i < 50000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
q.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_ConsumerGroup_1_Byte(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1) | ||
rand.Read(value) | ||
for i := 0; i < 500000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
cg, _ := q.ConsumerGroup("test") | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
cg.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_ConsumerGroup_128_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 128) | ||
rand.Read(value) | ||
for i := 0; i < 500000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
cg, _ := q.ConsumerGroup("test") | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
cg.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_ConsumerGroup_1024_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 1024) | ||
rand.Read(value) | ||
for i := 0; i < 200000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
cg, _ := q.ConsumerGroup("test") | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
cg.GetNext() | ||
} | ||
} | ||
|
||
func Benchmark_CGQueue_ConsumerGroup_10240_Bytes(b *testing.B) { | ||
q, _ := CGQueueOpen(cgQueueName, dir) | ||
defer q.Drop() | ||
value := make([]byte, 10240) | ||
rand.Read(value) | ||
for i := 0; i < 200000; i++ { | ||
q.Enqueue(value) | ||
} | ||
|
||
q.Close() | ||
q, _ = CGQueueOpen(cgQueueName, dir) | ||
cg, _ := q.ConsumerGroup("test") | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
cg.GetNext() | ||
} | ||
} |
Oops, something went wrong.