Skip to content

Commit

Permalink
Organize perf tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanElawady committed Oct 24, 2023
1 parent 1d2a5e9 commit caf5e81
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cmds/modules/noded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/threefoldtech/zos/pkg/events"
"github.com/threefoldtech/zos/pkg/monitord"
"github.com/threefoldtech/zos/pkg/perf"
"github.com/threefoldtech/zos/pkg/perf/cpubench"
"github.com/threefoldtech/zos/pkg/perf/iperf"
"github.com/threefoldtech/zos/pkg/registrar"
"github.com/threefoldtech/zos/pkg/stubs"
"github.com/threefoldtech/zos/pkg/utils"
Expand Down Expand Up @@ -202,10 +204,10 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "failed to create a new perfMon")
}

iperfTest := perf.NewIperfTest()
iperfTest := iperf.NewIperfTest()
perfMon.AddTask(&iperfTest)

cpuBenchmarkTask := perf.NewCPUBenchmarkTask()
cpuBenchmarkTask := cpubench.NewCPUBenchmarkTask()
perfMon.AddTask(&cpuBenchmarkTask)

if err = perfMon.Run(ctx); err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package perf
package cpubench

import (
"context"
"encoding/json"
"fmt"
"os/exec"

"github.com/threefoldtech/zos/pkg/perf"
"github.com/threefoldtech/zos/pkg/stubs"
)

Expand All @@ -28,7 +29,7 @@ type CPUBenchmarkResult struct {
Workloads int `json:"workloads"`
}

var _ Task = (*CPUBenchmarkTask)(nil)
var _ perf.Task = (*CPUBenchmarkTask)(nil)

// NewCPUBenchmarkTask returns a new CPU benchmark task.
func NewCPUBenchmarkTask() CPUBenchmarkTask {
Expand Down Expand Up @@ -59,7 +60,7 @@ func (c *CPUBenchmarkTask) Run(ctx context.Context) (interface{}, error) {
if err != nil {
return nil, fmt.Errorf("failed to parse cpubench output: %w", err)
}
client := GetZbusClient(ctx)
client := perf.GetZbusClient(ctx)
statistics := stubs.NewStatisticsStub(client)

workloads, err := statistics.Workloads(ctx)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package perf
package iperf

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/perf/iperf_task.go → pkg/perf/iperf/iperf_task.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package perf
package iperf

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/perf/iperf_types.go → pkg/perf/iperf/iperf_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package perf
package iperf

type iperfCommandOutput struct {
Start Start `json:"start"`
Expand Down

0 comments on commit caf5e81

Please sign in to comment.