Permalink
Browse files

changed gomaxprocs for performance

  • Loading branch information...
1 parent 05178a4 commit fd646c9edb03eeb7fb13b598651eb335d8ca32d7 @Inspiravetion committed Jan 30, 2014
View
Binary file not shown.
View
@@ -3,6 +3,7 @@ package main
import (
"io"
"os"
+ "runtime"
)
type ByteStream struct {
@@ -12,6 +13,8 @@ type ByteStream struct {
}
func main() {
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
for i := 0; i < 100; i++ {
stream := New_Byte_Stream(os.Args[1])
for _, err := stream.get_byte(); err == nil; _, err = stream.get_byte() {
View
Binary file not shown.
@@ -3,13 +3,16 @@ package main
import (
"io"
"os"
+ "runtime"
)
type ByteStream struct {
c <-chan byte
}
func main() {
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
for i := 0; i < 100; i++ {
stream := New_Byte_Stream(os.Args[1])
for _, err := stream.get_byte(); err == nil; _, err = stream.get_byte() {
View
Binary file not shown.
View
@@ -3,13 +3,16 @@ package main
import (
"io"
"os"
+ "runtime"
)
type ByteStream struct {
c <-chan byte
}
func main() {
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
for i := 0; i < 100; i++ {
stream := New_Byte_Stream(os.Args[1])
for _, err := stream.get_byte(); err == nil; _, err = stream.get_byte() {
View
@@ -1,5 +1,6 @@
This benchmark was to test how much overhead channels(buffered or unbuffered) have by testing sending single bytes vs arrays of bytes across a chanel.
+###GOMAXPROCS = 1
( .)(. ) Go>time ./ArrayByteStream ArrayByteStream.go
real 0m0.008s
@@ -43,4 +44,21 @@ sys 0m0.003s
real 0m0.024s
user 0m0.019s
-sys 0m0.003s
+sys 0m0.003s
+
+###GOMAXPROCS = 4(num cores)
+( .)(. ) Chan_Overhead_Test>time ./ArrayByteStream ArrayByteStream.go
+
+real 0m0.012s
+user 0m0.006s
+sys 0m0.007s
+( .)(. ) Chan_Overhead_Test>time ./ChanByteStream ArrayByteStream.go
+
+real 0m0.198s
+user 0m0.234s
+sys 0m0.067s
+( .)(. ) Chan_Overhead_Test>time ./BufferedChanByteStream ArrayByteStream.go
+
+real 0m0.035s
+user 0m0.043s
+sys 0m0.008s

0 comments on commit fd646c9

Please sign in to comment.