Created
January 31, 2016 18:07
-
-
Save DanielMorsing/c357f15c96afef0fdb76 to your computer and use it in GitHub Desktop.
the program
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 ( | |
"runtime/causalprof" | |
"net/http" | |
"bufio" | |
"os" | |
"math/rand" | |
"fmt" | |
"sync/atomic" | |
) | |
func main() { | |
http.HandleFunc("/", randomHandler) | |
go http.ListenAndServe(":9090", nil) | |
select{} | |
causalprof.Stop() | |
} | |
var reqcount int64 | |
func randomHandler(w http.ResponseWriter, req *http.Request) { | |
rq := atomic.AddInt64(&reqcount, 1) | |
if rq == 50000 { | |
causalprof.Start(os.Stdout) | |
} | |
p := causalprof.StartProgress() | |
buffered := bufio.NewWriter(w) | |
w.Header().Set("Content-Length", "20000") | |
for i := 0; i < 10000; i++ { | |
fmt.Fprintln(buffered, rand.Int63n(10)) | |
} | |
buffered.Flush() | |
p.Stop() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment