Created
May 29, 2012 00:53
-
-
Save taliesinb/2821943 to your computer and use it in GitHub Desktop.
Benchmarking SplitByte implementations from https://gist.github.com/2821937
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
package main | |
import "split" | |
import "time" | |
func main() { | |
long := make([]byte, 2 << 24) | |
for i := uint(1); i < 23; i++ { | |
long[2 << i] = 'X' | |
} | |
println("length\t", len(long)) | |
runs := 128 | |
t := time.Now() | |
println("mine") | |
data := SplitByte1(long, 'X') | |
for _, x := range data { | |
print(len(x),",") | |
} | |
println("other") | |
data = SplitByte2(long, 'X') | |
for _, x := range data { | |
print(len(x),",") | |
} | |
println("other") | |
data = SplitByte3(long, 'X') | |
for _, x := range data { | |
print(len(x),",") | |
} | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte1(long, 'X') | |
} | |
took := time.Now().Sub(t).Seconds() | |
println("mine\t", int(took * 1000)) | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte2(long, 'X') | |
} | |
took = time.Now().Sub(t).Seconds() | |
println("local\t", int(took * 1000)) | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte3(long, 'X') | |
} | |
took = time.Now().Sub(t).Seconds() | |
println("bytes\t", int(took * 1000)) | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte1(long, 'X') | |
} | |
took = time.Now().Sub(t).Seconds() | |
println("mine\t", int(took * 1000)) | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte2(long, 'X') | |
} | |
took = time.Now().Sub(t).Seconds() | |
println("local\t", int(took * 1000)) | |
t = time.Now() | |
for j := 1 ; j < runs ; j++ { | |
data = SplitByte3(long, 'X') | |
} | |
took = time.Now().Sub(t).Seconds() | |
println("bytes\t", int(took * 1000)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment