-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (60 loc) · 1.83 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"
"github.com/imdea-software/striver/controlplane"
dt "github.com/imdea-software/striver/datatypes"
"os/signal"
"os"
"github.com/imdea-software/striver/empirical"
"strconv"
"time"
)
func main() {
var lastEvent dt.FlowingEvent
//events := []dt.FlowingEvent{}
// inStreams, outStreams, killcb := empirical.ArrivalStock(100)
arg2,err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
maxevs,err := strconv.Atoi(os.Args[3])
if err != nil {
panic(err)
}
inStreams, outStreams, killcb := empirical.ArrivalStock(arg2,maxevs)
if os.Args[1]=="AVGK" {
fmt.Fprintf(os.Stderr, "Running AVGK with K=%d",arg2)
inStreams, outStreams, killcb = empirical.EffLastK(arg2,maxevs)
} else {
fmt.Fprintf(os.Stderr, "Running STOCK with P=%d",arg2)
}
fmt.Fprintf(os.Stderr, ", maxevs=%d\n",maxevs)
//inStreams, outStreams := shiftExample()
// inStreams, outStreams := changePointsExample()
//inStreams, outStreams := clockExample()
kchan := make (chan bool)
outchan := make (chan dt.FlowingEvent)
go func(){
for ev := range outchan {
lastEvent = ev
//events = append(events, ev)
}
}()
// Catch interruption
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func(){
for _ = range c {
close(kchan)
}
}()
start := time.Now()
controlplane.Start(inStreams, outStreams, outchan, kchan)
elapsed := time.Since(start)
//fmt.Fprintf(os.Stderr, "Took %f seconds\n", elapsed.Seconds())
fmt.Fprintf(os.Stderr, "Event ratio is %f events per second\n", float64(maxevs)/(elapsed.Seconds()))
fmt.Println("End of execution")
killcb()
fmt.Println(lastEvent)
//fmt.Println(events[0])
}