Skip to content

Commit

Permalink
return the correct benchamrk path
Browse files Browse the repository at this point in the history
  • Loading branch information
wjiec committed Nov 7, 2023
1 parent f4d2ca6 commit 38d96aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions internal/perf/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const (
k9sUA = "k9s/"
)


var (
// K9sBenchDir directory to store K9s Benchmark files.
K9sBenchDir = filepath.Join(os.TempDir(), fmt.Sprintf("k9s-bench-%s", config.MustK9sUser()))
Expand Down Expand Up @@ -107,15 +106,15 @@ func (b *Benchmark) Canceled() bool {
return b.canceled
}

// Run starts a benchmark,.
// Run starts a benchmark.
func (b *Benchmark) Run(cluster string, done func()) {
log.Debug().Msgf("Running benchmark on cluster %s", cluster)
buff := new(bytes.Buffer)
b.worker.Writer = buff
// this call will block until the benchmark is complete or times out.
b.worker.Run()
b.worker.Stop()
if len(buff.Bytes()) > 0 {
if buff.Len() > 0 {
if err := b.save(cluster, buff); err != nil {
log.Error().Err(err).Msg("Saving Benchmark")
}
Expand All @@ -141,11 +140,7 @@ func (b *Benchmark) save(cluster string, r io.Reader) error {
}
}()

bb, err := io.ReadAll(r)
if err != nil {
return err
}
if _, err := f.Write(bb); err != nil {
if _, err = io.Copy(f, r); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion internal/view/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func fileToSubject(path string) string {
}

func benchDir(cfg *config.Config) string {
return filepath.Join(perf.K9sBenchDir, cfg.K9s.CurrentContextDir())
return filepath.Join(perf.K9sBenchDir, cfg.K9s.CurrentCluster)
}

func readBenchFile(cfg *config.Config, n string) (string, error) {
Expand Down

0 comments on commit 38d96aa

Please sign in to comment.