Skip to content

Commit

Permalink
add count option to 'stat diff' for benchmark
Browse files Browse the repository at this point in the history
Signed-off-by: Naoki MATSUMOTO <[email protected]>
  • Loading branch information
naoki9911 committed Apr 19, 2024
1 parent b30aab1 commit 15dfa7f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
16 changes: 15 additions & 1 deletion cmd/ctr-cli/stat/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"time"

"github.com/naoki9911/fuse-diff-containerd/pkg/benchmark"
Expand Down Expand Up @@ -103,6 +104,11 @@ func diffCommand() *cli.Command {
Required: false,
Value: "pathB",
},
&cli.IntFlag{
Name: "count",
Required: false,
Value: 1,
},
},
}

Expand Down Expand Up @@ -134,7 +140,15 @@ func diffAction(c *cli.Context) error {
}

defer fmt.Println("done")
return diffImpl(pathA, pathB, pm, b, c.String("pathALabel"), c.String("pathBLabel"), pathA, pathB)
for i := 0; i < c.Int("count"); i++ {
b.SetLabel("count", strconv.Itoa(i))
err = diffImpl(pathA, pathB, pm, b, c.String("pathALabel"), c.String("pathBLabel"), pathA, pathB)
if err != nil {
return err
}
}

return nil
}

func doBoth[T, U any](pathA, pathB T, f func(path T) (U, error)) (U, U, error) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (b *Benchmark) SetDefaultLabels(l map[string]string) {
b.defaultLabels = l
}

func (b *Benchmark) SetLabel(k, v string) {
b.defaultLabels[k] = v
}

func (b *Benchmark) Close() error {
err := b.logFile.Close()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/bench_impl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ for ((i=0; i < $(expr ${#IMAGE_VERSIONS[@]} - 1); i++));do
fi
set -u

$BIN_CTR_CLI --labels $LABELS,old:$LOWER,new:$UPPER,mode:binary-diff,out:$LOWER-$UPPER stat diff --benchmark --pathALabel native --pathBLabel di3fs $UPPER /tmp/fuse
$BIN_CTR_CLI --labels $LABELS,old:$LOWER,new:$UPPER,mode:binary-diff,out:$LOWER-$UPPER stat diff --benchmark --pathALabel native --pathBLabel di3fs --count 5 $UPPER /tmp/fuse
fi
fusermount3 -u /tmp/fuse
done
Expand Down
2 changes: 2 additions & 0 deletions tests/plot_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# ignore 0-bytes file
if fileSize == 0:
continue
if labels["count"] != "0":
continue
elapsedUS = r["elapsedMicroseconds"]
tag = "{}".format(pathLabel)
if tag not in stat_open:
Expand Down
2 changes: 2 additions & 0 deletions tests/plot_file_io_with_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
continue
if pathLabel != "di3fs":
continue
if labels["count"] != "0":
continue
tag = "{}:{}-{}".format(imageName, old, new)
entryType = files[tag][path]

Expand Down

0 comments on commit 15dfa7f

Please sign in to comment.