-
Notifications
You must be signed in to change notification settings - Fork 1
/
getRuntime.go
132 lines (110 loc) · 3.45 KB
/
getRuntime.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package stats
import "time"
// GetCoSchedCATRuntimes returns the runtime of application when running in parallel to cosched with CAT
func GetCoSchedCATRuntimes(application string, cosched string) *map[int]RuntimeT {
temp, exists := runtimeStats.Runtimes[application]
if !exists {
return nil
}
if (*temp).CoSchedCATRuntimes == nil {
return nil
}
ret, exists := (*(*temp).CoSchedCATRuntimes)[cosched]
if exists {
return &ret
}
return nil
}
// GetCoSchedCATRuntimes returns the runtime of application when running in parallel to cosched with CAT
func GetCoSchedCATRuntimesNormalized(application string, cosched string) *map[int]RuntimeT {
ref := GetReferenceRuntime(application)
cat := GetCoSchedCATRuntimes(application, cosched)
if ref == nil || cat == nil {
return nil
}
meanInNanoseconds := int64(ref.Mean * 1e+9)
ret := make(map[int]RuntimeT)
for catKey, catR := range *cat {
ret[catKey] = normalizeRuntimeT(catR, meanInNanoseconds)
}
return &ret
}
// GetCoSchedRuntimes returns the runtime of application when running in parallel to cosched without CAT
func GetCoSchedRuntimes(application string, cosched string) *RuntimeT {
temp, exists := runtimeStats.Runtimes[application]
if !exists {
return nil
}
if (*temp).CoSchedRuntimes == nil {
return nil
}
ret, exists := (*temp.CoSchedRuntimes)[cosched]
if !exists {
return nil
}
return &ret
}
// GetCoSchedRuntimesNormalized returns the normalized runtime of application when running in parallel to cosched without CAT
func GetCoSchedRuntimesNormalized(application string, cosched string) *RuntimeT {
ref := GetReferenceRuntime(application)
co := GetCoSchedRuntimes(application, cosched)
if ref == nil || co == nil {
return nil
}
meanInNanoseconds := int64(ref.Mean * 1e+9)
ret := normalizeRuntimeT(*co, meanInNanoseconds)
return &ret
}
// GetCATRuntimes returns all cat individual runtimes with CAT
func GetCATRuntimes(application string) *map[int]RuntimeT {
_, exists := runtimeStats.Runtimes[application]
if exists {
return runtimeStats.Runtimes[application].CATRuntimes
}
return nil
}
// GetCATRuntimesNormalized returns all cat individual runtimes with CAT normalized
func GetCATRuntimesNormalized(application string) *map[int]RuntimeT {
ref := GetReferenceRuntime(application)
cat := GetCATRuntimes(application)
if ref == nil || cat == nil {
return nil
}
meanInNanoseconds := int64(ref.Mean * 1e+9)
ret := make(map[int]RuntimeT)
for catKey, catR := range *cat {
ret[catKey] = normalizeRuntimeT(catR, meanInNanoseconds)
}
return &ret
}
// GetReferenceRuntime returns the individual runtime without CAT
func GetReferenceRuntime(application string) *RuntimeT {
_, exists := runtimeStats.Runtimes[application]
if exists {
return &runtimeStats.Runtimes[application].ReferenceRuntimes
}
return nil
}
// GetReferenceRuntimeNormalized returns the individual runtime without CAT normalized
func GetReferenceRuntimeNormalized(application string) *RuntimeT {
ref := GetReferenceRuntime(application)
if ref == nil {
return nil
}
meanInNanoseconds := int64(ref.Mean * 1e+9)
ret := normalizeRuntimeT(*ref, meanInNanoseconds)
return &ret
}
func normalizeRuntimeT(ref RuntimeT, meanInNanoseconds int64) RuntimeT {
var rs []DataPerRun
for _, v := range *ref.RawRuntimesByMask {
for _, t := range v {
var r DataPerRun
r.Output = t.Output
r.Runtime = time.Duration(int64(t.Runtime) / meanInNanoseconds)
rs = append(rs, r)
}
}
ret := newRuntimeT(NoCATMask, rs)
return ret
}