-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (59 loc) · 1.27 KB
/
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
62
63
64
65
66
package main
import (
"fmt"
"os"
"strconv"
"time"
"github.com/jakobgt/cay"
"github.com/pkg/profile"
)
func main() {
size := 1 << 10
iterations := 1
if len(os.Args) > 1 {
s, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Printf("%s is not a valid size. should be an int", os.Args[1])
return
}
size = s
}
if len(os.Args) > 2 {
iter, err := strconv.Atoi(os.Args[2])
if err != nil {
fmt.Printf("%s is not count number. should be an int", os.Args[2])
return
}
iterations = iter
}
// We initialize
fmt.Println("Warming up")
keys := cay.RandomKeys(size)
m := cay.Simdmap(keys)
readAll(m, keys)
fmt.Println("Running test")
pr := profile.Start(profile.CPUProfile, profile.ProfilePath("."))
start := time.Now()
for i := 0; i < iterations; i++ {
readAll(m, keys)
}
timing := time.Now().Sub(start)
pr.Stop()
ops_per_sec := timing.Nanoseconds() / (int64(iterations) * int64(size))
fmt.Printf("Total time: %dns\n", timing.Nanoseconds())
fmt.Printf("Size: %d, Iterations: %d\n", size, iterations)
fmt.Printf("Ops per seco %d ns\n", ops_per_sec)
//for _, k := range keys {
// m.Get(k)
//}
//
//// Now we measure
}
func readAll(m *cay.Map, keys []string) {
for _, k := range keys {
v, ok := m.Get(k)
if !ok {
fmt.Println(v)
}
}
}