Newer
Older
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
package main
import (
"bytes"
"fmt"
"io/ioutil"
"runtime/pprof"
"time"
bnet "github.com/bio-routing/bio-rd/net"
)
func main() {
for i := 0; i < 255; i++ {
for j := 0; j < 255; j++ {
for k := 0; k < 11; k++ {
addr := bnet.IPv4FromOctets(10, uint8(i), uint8(j), uint8(k))
addr.Dedup()
}
}
}
buf := bytes.NewBuffer(nil)
err := pprof.StartCPUProfile(buf)
if err != nil {
panic(err)
}
start := time.Now().UnixNano()
for x := 0; x < 1; x++ {
for i := 0; i < 255; i++ {
for j := 0; j < 255; j++ {
for k := 0; k < 11; k++ {
addr := bnet.IPv4FromOctets(10, uint8(i), uint8(j), uint8(k))
addr.Dedup()
}
}
}
}
end := time.Now().UnixNano()
d := end - start
pprof.StopCPUProfile()
fmt.Printf("Looking up IP-Addresses took %d ms\n", d/1000000)
ioutil.WriteFile("profile.pprof", buf.Bytes(), 0644)
x := bytes.NewBuffer(nil)
pprof.WriteHeapProfile(x)
ioutil.WriteFile("heap.pprof", x.Bytes(), 0644)
}