-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
95 lines (85 loc) · 1.99 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
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
package main
import (
ep "NPB-Golang/EP"
is "NPB-Golang/IS"
"NPB-Golang/commons"
"fmt"
"os"
)
// required params: {benchmark} CLASS={class}
// optional param: {-f file_name}
// optional param: USE_BUCKETS (must be the last argument, default: do not use buckets)
func main() {
args := os.Args[1:]
if len(args) < 2 {
_, _ = fmt.Fprintln(os.Stderr, "Invalid number of required arguments")
os.Exit(1)
}
var benchmark func()
commons.Benchmark, benchmark = getBenchmark(args[0])
commons.Class = getClass(args[1])
if len(args) > 2 && args[2] == "-f" {
var fileArg string
if len(args) > 3 && args[3] != "USE_BUCKETS" {
fileArg = args[3]
}
commons.File = getFile(commons.Benchmark, commons.Class, fileArg)
}
if commons.Benchmark == "IS" {
if args[len(args)-1] == "USE_BUCKETS" {
is.RankFunction, is.FullVerifyFunction = is.Rank, is.FullVerify
}
}
benchmark()
}
func getBenchmark(benchmark_arg string) (benchmark string, benchmarkFunc func()) {
switch benchmark_arg {
case "EP":
benchmark = "EP"
benchmarkFunc = ep.ExecEP
case "IS":
benchmark = "IS"
benchmarkFunc = is.ExecIS
default:
fmt.Println("Incorrect benchmark argument")
os.Exit(1)
}
return benchmark, benchmarkFunc
}
func getClass(class_arg string) (class string) {
switch class_arg {
case "CLASS=S":
class = "S"
case "CLASS=W":
class = "W"
case "CLASS=A":
class = "A"
case "CLASS=B":
class = "B"
case "CLASS=C":
class = "C"
case "CLASS=D":
class = "D"
case "CLASS=E":
class = "E"
default:
_, _ = fmt.Fprintln(os.Stderr, "Invalid class argument")
os.Exit(1)
}
return class
}
func getFile(benchmark string, class string, file_arg string) (file *os.File) {
var fileName string
if len(file_arg) != 0 {
fileName = file_arg
} else {
fileName = benchmark + "_" + class + ".txt"
}
var err error
file, err = os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, "file could not be open/created")
return nil
}
return file
}