/
main.go
61 lines (51 loc) · 875 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
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"log"
"net"
"os"
"runtime/pprof"
)
func main() {
// add profiling
f, err := os.Create("cpu.pprof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
// main code
connection := makeConnection()
data := download(connection)
closeConnection(connection)
fmt.Printf("Download was: %v", data)
}
func makeConnection() net.Conn {
waste := 0
for x := 0; x < 10*100000000; x++ {
// waste some CPU
waste++
}
println(waste)
// not implemented
return nil
}
func download(conn net.Conn) []byte {
waste := 0
for x := 0; x < 100*100000000; x++ {
// waste some CPU
waste++
}
println(waste)
// not implemented
return nil
}
func closeConnection(conn net.Conn) {
waste := 0
for x := 0; x < 5*100000000; x++ {
// waste some CPU
waste++
}
println(waste)
// not implemented
}