Last active
August 29, 2015 14:08
-
-
Save sunzhongwei/3b0573d528fdfd6ba1a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Copyright 2014 Zhongwei Inc. | |
Author: Zhongwei Sun | |
EMail: [email protected] | |
$ ab -n 50 -c 5 http://localhost:9000/ | |
*/ | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
) | |
func indexHandler(w http.ResponseWriter, r *http.Request) { | |
fmt.Println("Start at:", time.Now()) | |
time.Sleep(2 * time.Second) | |
fmt.Fprintf(w, "Hi there, I love %s!\n", r.URL.Path[1:]) | |
fmt.Println("End at:", time.Now()) | |
} | |
func main() { | |
port := 9000 | |
fmt.Println("Start server on port:", port) | |
http.HandleFunc("/", indexHandler) | |
http.ListenAndServe(fmt.Sprintf(":%v", port), nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment