-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
48 lines (41 loc) · 773 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"log"
"net/http"
"runtime"
"time"
_ "net/http/pprof"
_ "github.com/mkevac/debugcharts"
"github.com/gorilla/handlers"
)
func dummyCPUUsage() {
var a uint64
var t = time.Now()
for {
t = time.Now()
a += uint64(t.Unix())
}
}
func dummyAllocations() {
var d []uint64
for {
for i := 0; i < 2*1024*1024; i++ {
d = append(d, 42)
}
time.Sleep(time.Second * 10)
fmt.Println(len(d))
d = make([]uint64, 0)
runtime.GC()
time.Sleep(time.Second * 10)
}
}
func main() {
go dummyAllocations()
go dummyCPUUsage()
go func() {
log.Fatal(http.ListenAndServe(":8080", handlers.CompressHandler(http.DefaultServeMux)))
}()
log.Printf("you can now open http://localhost:8080/debug/charts/ in your browser")
select {}
}