-
Notifications
You must be signed in to change notification settings - Fork 50
/
main.go
105 lines (88 loc) · 2.76 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
96
97
98
99
100
101
102
103
104
105
/*
Copyright The Soci Snapshotter Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"flag"
"fmt"
"os"
"testing"
"github.com/awslabs/soci-snapshotter/benchmark"
"github.com/awslabs/soci-snapshotter/benchmark/framework"
)
var (
outputDir = "../comparisonTest/output"
)
func main() {
var (
numberOfTests int
configFile string
showCom bool
imageList []benchmark.ImageDescriptor
err error
commit string
)
flag.BoolVar(&showCom, "show-commit", false, "tag the commit hash to the benchmark results")
flag.IntVar(&numberOfTests, "count", 5, "Describes the number of runs a benchmarker should run. Default: 5")
flag.StringVar(&configFile, "f", "default", "Path to a file describing image details as a json file or csv in this order ['Name','Image ref', 'Ready line', 'manifest ref'].")
flag.Parse()
if showCom {
commit, _ = benchmark.GetCommitHash()
} else {
commit = "N/A"
}
if configFile == "default" {
imageList = benchmark.GetDefaultWorkloads()
} else {
imageList, err = benchmark.GetImageList(configFile)
if err != nil {
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", configFile, err)
panic(errMsg)
}
}
err = os.Mkdir(outputDir, 0755)
if err != nil && !os.IsExist(err) {
panic(err)
}
logFile, err := os.OpenFile(outputDir+"/benchmark_log", os.O_RDWR|os.O_CREATE, 0664)
if err != nil {
panic(err)
}
defer logFile.Close()
ctx, cancelCtx := framework.GetTestContext(logFile)
defer cancelCtx()
var drivers []framework.BenchmarkTestDriver
for _, image := range imageList {
image := image
shortName := image.ShortName
drivers = append(drivers, framework.BenchmarkTestDriver{
TestName: "OverlayFSFull" + shortName,
NumberOfTests: numberOfTests,
TestFunction: func(b *testing.B) {
benchmark.OverlayFSFullRun(ctx, b, "OverlayFSFull"+shortName, image)
},
})
drivers = append(drivers, framework.BenchmarkTestDriver{
TestName: "SociFull" + shortName,
NumberOfTests: numberOfTests,
TestFunction: func(b *testing.B) {
benchmark.SociFullRun(ctx, b, "SociFull"+shortName, image)
},
})
}
benchmarks := framework.BenchmarkFramework{
OutputDir: outputDir,
CommitID: commit,
Drivers: drivers,
}
benchmarks.Run(ctx)
}