Skip to content

Instantly share code, notes, and snippets.

@caesaneer
Created August 18, 2019 22:10
Show Gist options
  • Save caesaneer/b918e27099b2186bf5a83206bc838e94 to your computer and use it in GitHub Desktop.
Save caesaneer/b918e27099b2186bf5a83206bc838e94 to your computer and use it in GitHub Desktop.
Golang - Single and 16 CPU Threads
package main
import (
"benchmarks/pkg/bench"
"fmt"
"net/http"
"runtime"
)
func helloServer(w http.ResponseWriter, r *http.Request) {
bench.CPU(100)
fmt.Fprintf(w, "OK")
}
func main() {
// Comment out this line for non single CPU thread benchmark
runtime.GOMAXPROCS(1)
a := "192.168.0.14:7000"
http.HandleFunc("/", helloServer)
fmt.Println("Go HTTP Server Running at:", a)
http.ListenAndServe(a, nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment