forked from awslabs/soci-snapshotter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
122 lines (105 loc) · 3.28 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
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"
bparser "github.com/awslabs/soci-snapshotter/benchmark/framework/parser"
)
var (
outputDir = "../performanceTest/output"
)
func main() {
var (
numberOfTests int
configCsv string
showCom bool
parseFileAccessPatterns bool
commit string
imageList []benchmark.ImageDescriptor
err error
)
flag.BoolVar(&parseFileAccessPatterns, "parse-file-access", false, "Parse fuse file access patterns.")
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(&configCsv, "f", "default", "Path to a csv file describing image details in this order ['Name','Image ref', 'Ready line', 'manifest ref'].")
flag.Parse()
if showCom {
commit, _ = benchmark.GetCommitHash()
} else {
commit = "N/A"
}
if parseFileAccessPatterns {
fileAccessDir := outputDir + "/file_access_logs"
err := os.RemoveAll(fileAccessDir)
if err != nil {
panic(err)
}
err = os.MkdirAll(fileAccessDir, 0755)
if err != nil {
panic(err)
}
}
if configCsv == "default" {
imageList = benchmark.GetDefaultWorkloads()
} else {
imageList, err = benchmark.GetImageListFromCsv(configCsv)
if err != nil {
errMsg := fmt.Sprintf("Failed to read csv file %s with error:%v\n", configCsv, 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 {
shortName := image.ShortName
imageRef := image.ImageRef
sociIndexManifestRef := image.SociIndexManifestRef
readyLine := image.ReadyLine
testName := "SociFull" + shortName
driver := framework.BenchmarkTestDriver{
TestName: testName,
NumberOfTests: numberOfTests,
TestFunction: func(b *testing.B) {
benchmark.SociFullRun(ctx, b, imageRef, sociIndexManifestRef, readyLine, testName)
},
}
if parseFileAccessPatterns {
driver.AfterFunction = func() error {
err := bparser.ParseFileAccesses(shortName)
return err
}
}
drivers = append(drivers, driver)
}
benchmarks := framework.BenchmarkFramework{
OutputDir: outputDir,
CommitID: commit,
Drivers: drivers,
}
benchmarks.Run(ctx)
}