-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
55 lines (45 loc) · 1.04 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
package main
// read in input
// initialize objects
import (
"fmt"
"os"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
args := os.Args[1:]
conf := readConf(args[0])
var logger = make(chan LogEvent, 1000)
loggingDone := make(chan bool)
go log(logger, loggingDone)
var eventQueue EventQueue
switch {
case conf.Read:
fr := makeFlowReader(conf.TraceFileName)
eventQueue = fr.makeFlows(logger)
case conf.GenerateOnly:
fg := makeFlowGenerator(conf.Load, conf.Bandwidth, conf.CDFFileName, conf.NumFlows)
eventQueue = fg.makeFlows(logger)
close(logger)
<-loggingDone
return
case conf.Generate:
fg := makeFlowGenerator(conf.Load, conf.Bandwidth, conf.CDFFileName, conf.NumFlows)
eventQueue = fg.makeFlows(logger)
default:
panic("Invalid configuration")
}
flows := ideal(conf.Bandwidth, logger, eventQueue)
close(logger)
<-loggingDone
numFlows := len(flows)
slowdown := 0.0
for i := 0; i < numFlows; i++ {
slowdown += calculateFlowSlowdown(flows[i])
}
fmt.Println(slowdown / float64(numFlows))
}