Skip to content

Commit 21b8eff

Browse files
committed
Remove benchmarker CSV input in favor of JSON awslabs#946
Signed-off-by: Scott Haddlesey <[email protected]>
1 parent 2cb31a4 commit 21b8eff

File tree

5 files changed

+35
-58
lines changed

5 files changed

+35
-58
lines changed

benchmark/comparisonTest/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func main() {
3434

3535
var (
3636
numberOfTests int
37-
configFile string
37+
jsonFile string
3838
showCom bool
3939
imageList []benchmark.ImageDescriptor
4040
err error
@@ -43,7 +43,7 @@ func main() {
4343

4444
flag.BoolVar(&showCom, "show-commit", false, "tag the commit hash to the benchmark results")
4545
flag.IntVar(&numberOfTests, "count", 5, "Describes the number of runs a benchmarker should run. Default: 5")
46-
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'].")
46+
flag.StringVar(&jsonFile, "f", "default", "Path to a json file describing image details in this order ['Name','Image ref', 'Ready line', 'manifest ref']")
4747

4848
flag.Parse()
4949

@@ -53,12 +53,12 @@ func main() {
5353
commit = "N/A"
5454
}
5555

56-
if configFile == "default" {
56+
if jsonFile == "default" {
5757
imageList = benchmark.GetDefaultWorkloads()
5858
} else {
59-
imageList, err = benchmark.GetImageList(configFile)
59+
imageList, err = benchmark.GetImageList(jsonFile)
6060
if err != nil {
61-
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", configFile, err)
61+
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", jsonFile, err)
6262
panic(errMsg)
6363
}
6464
}

benchmark/performanceTest/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535

3636
var (
3737
numberOfTests int
38-
configFile string
38+
jsonFile string
3939
showCom bool
4040
parseFileAccessPatterns bool
4141
commit string
@@ -46,7 +46,7 @@ func main() {
4646
flag.BoolVar(&parseFileAccessPatterns, "parse-file-access", false, "Parse fuse file access patterns.")
4747
flag.BoolVar(&showCom, "show-commit", false, "tag the commit hash to the benchmark results")
4848
flag.IntVar(&numberOfTests, "count", 5, "Describes the number of runs a benchmarker should run. Default: 5")
49-
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'].")
49+
flag.StringVar(&jsonFile, "f", "default", "Path to a json file describing image details in this order ['Name','Image ref', 'Ready line', 'manifest ref']")
5050

5151
flag.Parse()
5252

@@ -68,12 +68,12 @@ func main() {
6868
}
6969
}
7070

71-
if configFile == "default" {
71+
if jsonFile == "default" {
7272
imageList = benchmark.GetDefaultWorkloads()
7373
} else {
74-
imageList, err = benchmark.GetImageList(configFile)
74+
imageList, err = benchmark.GetImageList(jsonFile)
7575
if err != nil {
76-
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", configFile, err)
76+
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", jsonFile, err)
7777
panic(errMsg)
7878
}
7979
}

benchmark/stargzTest/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ var (
3232

3333
func main() {
3434
commit := os.Args[1]
35-
configFile := os.Args[2]
35+
jsonFile := os.Args[2]
3636
numberOfTests, err := strconv.Atoi(os.Args[3])
3737
stargzBinary := os.Args[4]
3838
if err != nil {
3939
errMsg := fmt.Sprintf("Failed to parse number of test %s with error:%v\n", os.Args[3], err)
4040
panic(errMsg)
4141
}
42-
imageList, err := benchmark.GetImageList(configFile)
42+
imageList, err := benchmark.GetImageList(jsonFile)
4343
if err != nil {
44-
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", configFile, err)
44+
errMsg := fmt.Sprintf("Failed to read file %s with error:%v\n", jsonFile, err)
4545
panic(errMsg)
4646
}
4747

benchmark/utils.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
package benchmark
1818

1919
import (
20-
"encoding/csv"
2120
"encoding/json"
22-
"errors"
2321
"fmt"
2422
"io"
2523
"os"
@@ -109,15 +107,7 @@ func GetImageList(file string) ([]ImageDescriptor, error) {
109107
return nil, err
110108
}
111109
defer f.Close()
112-
images, jsonErr := GetImageListFromJSON(f)
113-
if jsonErr == nil {
114-
return images, nil
115-
}
116-
images, csvErr := GetImageListFromCsv(f)
117-
if csvErr == nil {
118-
return images, nil
119-
}
120-
return nil, errors.Join(jsonErr, csvErr)
110+
return GetImageListFromJSON(f)
121111

122112
}
123113

@@ -130,29 +120,6 @@ func GetImageListFromJSON(r io.Reader) ([]ImageDescriptor, error) {
130120
return images, nil
131121
}
132122

133-
func GetImageListFromCsv(r io.Reader) ([]ImageDescriptor, error) {
134-
csv, err := csv.NewReader(r).ReadAll()
135-
if err != nil {
136-
return nil, err
137-
}
138-
var images []ImageDescriptor
139-
for _, image := range csv {
140-
if len(image) < 3 {
141-
return nil, errors.New("image input is not sufficient")
142-
}
143-
var sociIndexManifestRef string
144-
if len(image) == 4 {
145-
sociIndexManifestRef = image[2]
146-
}
147-
images = append(images, ImageDescriptor{
148-
ShortName: image[0],
149-
ImageRef: image[1],
150-
ReadyLine: image[3],
151-
SociIndexDigest: sociIndexManifestRef})
152-
}
153-
return images, nil
154-
}
155-
156123
func GetCommitHash() (string, error) {
157124
cmd := exec.Command("git", "rev-parse", "HEAD")
158125
output, err := cmd.Output()

docs/benchmark.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are two types of benchmarks:
1212
- [Running benchmarks on default workloads](#running-benchmarks-on-default-workloads)
1313
- [Running benchmarks on custom workloads](#running-benchmarks-on-custom-workloads)
1414
- [Benchmark binaries cli flags](#benchmark-binaries-have-different-cli-flags)
15-
- [Csv file format for custom workloads](#csv-file-format-for-custom-workloads)
15+
- [JSON file format for custom workloads](#json-file-format-for-custom-workloads)
1616
- [Default workloads](#default-workloads)
1717
- [Benchmark results format](#benchmark-results)
1818

@@ -36,31 +36,41 @@ Custom workloads can also be benchmarked with SOCI.
3636

3737
In order to run the benchmarks on custom workloads the custom container image needs to have its soci indices generated and pushed to a contianer registry as described in the [Getting started docs](/docs/getting-started.md)
3838

39-
Generate benchmark binaries:
39+
Generate benchmark binaries:
4040
``` make build-benchmarks``` will generate benchmark binaries for performance testing and comparison testing against overlayFS. The binaries will be available in the ```/benchmark/bin``` folder.
41-
42-
### Benchmark binaries have different cli flags:
41+
42+
### Benchmark binaries have different cli flags:
4343

4444
| Flag | Description | Required / Optional |
4545
|----------|----------|----------|
46-
| ```-f``` | File path to a csv file containing details of multiple images to be tested | Optional
46+
| ```-f``` | File path to a json file containing details of multiple images to be tested | Optional
4747
| ```-count``` | Specify number of times the benchmarker needs to run | Optional
4848
| ```-show-commit``` | Tag the latest commit hash to the benchmark results | Optional
4949

50-
We can now run benchmarks on custom workloads using the ```-f``` flag to specify the file path to a csv file containing details of the workloads.
50+
We can now run benchmarks on custom workloads using the ```-f``` flag to specify the file path to a json file containing details of the workloads.
5151

52-
### Csv file format for custom workloads
52+
### JSON file format for custom workloads
5353

5454
Ensure that the file being used with the ```-f``` flag follows the following format
5555

56-
```shell
57-
<Test_name>, <Container_Image_ref>, <Ready_line>, <Soci_Index_Manifest_Digest>
56+
```json
57+
{
58+
"short_name": "<Test_name>",
59+
"image_ref": "<Container_Image_ref>",
60+
"ready_line": "<Ready_line>",
61+
"soci_index_digest": "<Soci_Index_Manifest_Digest>"
62+
}
5863
```
5964

6065
Example :
6166

62-
```shell
63-
ffmpeg, public.ecr.aws/soci-workshop-examples/ffmpeg:latest, "Hello World",ef63578971ebd8fc700c74c96f81dafab4f3875e9117ef3c5eb7446e169d91cb
67+
```json
68+
{
69+
"short_name": "ffmpeg",
70+
"image_ref": "public.ecr.aws/soci-workshop-examples/ffmpeg:latest",
71+
"ready_line": "Hello World",
72+
"soci_index_digest": "ef63578971ebd8fc700c74c96f81dafab4f3875e9117ef3c5eb7446e169d91cb"
73+
}
6474
```
6575

6676
### Default workloads

0 commit comments

Comments
 (0)