Skip to content

Instantly share code, notes, and snippets.

@taliesinb
Created May 29, 2012 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taliesinb/2821943 to your computer and use it in GitHub Desktop.
Save taliesinb/2821943 to your computer and use it in GitHub Desktop.
Benchmarking SplitByte implementations from https://gist.github.com/2821937
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