Skip to content

Commit

Permalink
tested output file code with different directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mchinta7 committed Jan 5, 2024
1 parent 96b3dbf commit 665b1aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ go.work
result/

#tmp folder which contains .yaml files
tmp/
tmp/

#.txt files which contain response stats
.txt
10 changes: 7 additions & 3 deletions cmd/kperf/commands/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package runner
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"sort"

"github.com/Azure/kperf/api/types"
Expand Down Expand Up @@ -83,9 +83,9 @@ var runCommand = cli.Command{

var f *os.File = os.Stdout
if outputFilePath != "" {
err := os.MkdirAll(outputFilePath, os.ModePerm)
err := os.MkdirAll(filepath.Dir(outputFilePath), 0600)
if err != nil {
log.Default().Printf("failed to create directory %s: %v", outputFilePath, err)
return err
}
f, err = os.Create(outputFilePath)
if err != nil {
Expand Down Expand Up @@ -136,6 +136,10 @@ func printResponseStats(f *os.File, stats *types.ResponseStats) {

fmt.Fprintf(f, " Total Failures: %d\n", len(stats.FailureList))

for _, v := range stats.FailureList {
fmt.Fprintf(f, " %v\n", v)
}

fmt.Fprintf(f, " Observed Bytes: %v\n", stats.TotalReceivedBytes)

fmt.Fprintf(f, " Duration: %v\n", stats.Duration.String())
Expand Down

0 comments on commit 665b1aa

Please sign in to comment.