-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (47 loc) · 1.2 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
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"projekt1/control"
"time"
)
// Przykład użycia
func main() {
// wyłączenie logów
//log.SetOutput(io.Discard)
//verticesAmountPTR := flag.Int("vertices", 10, "Number of vertices")
//doBrunteForcePTR := flag.Bool("brute-force", false, "Do brute force")
logToFilePTR := flag.Bool("log-to-file", false, "Log to file")
runMenuPTR := flag.Bool("control", true, "Run control, if false run default tests")
flag.Parse()
//
if *logToFilePTR {
//save all logs to file
dateString := time.Now().Format("2006-01-02_15:04:05")
logFileName := dateString + ".log"
f, err := os.OpenFile(logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
fmt.Println("Error opening file:", err)
} else {
defer func(f *os.File) {
err := f.Close()
if err != nil {
fmt.Println("Error closing file:", err)
}
}(f)
multi := io.MultiWriter(f, os.Stdout)
log.SetOutput(multi)
}
}
if *runMenuPTR {
control.Menu()
} else {
control.RunSingleTest(100, 13, 6, 1, "DP.csv")
control.RunSingleTest(100, 13, 6, 2, "BNB.csv")
control.RunSingleTest(100, 13, 6, 3, "NBNB.csv")
control.RunSingleTest(100, 13, 6, 0, "BF.csv")
}
}