Skip to content

Commit

Permalink
Add warmup and sampleDelay
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <rsevilla@redhat.com>
  • Loading branch information
rsevilla87 committed May 10, 2023
1 parent 0cfa97b commit bf7adc4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
14 changes: 14 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@ import (

var Cfg []Config

// UnmarshalYAML implements YAML unmarshalleer to set default values in the config
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
type ConfigDefaulted Config
defaultCfg := ConfigDefaulted{
Warmup: false, // Disable warmup by default
}
if err := unmarshal(&defaultCfg); err != nil {
return err
}
*c = Config(defaultCfg)
return nil
}

func Load(cfg string) error {
f, err := os.Open(cfg)
if err != nil {
return err
}
data := yaml.NewDecoder(f)
data.KnownFields(true)
err = data.Decode(&Cfg)
return err
}
2 changes: 2 additions & 0 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ type Config struct {
Tool string `yaml:"tool" json:"tool"`
ServerReplicas int32 `yaml:"serverReplicas" json:"serverReplicas"`
Tuning string `yaml:"tuningPatch" json:"tuningPatch"`
SampleDelay time.Duration `yaml:"sampleDelay"`
Warmup bool `yaml:"warmup" json:"-"`
}
5 changes: 4 additions & 1 deletion pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func runBenchmark(cfg config.Config, clusterMetadata ocpmetadata.ClusterMetadata
ClusterMetadata: clusterMetadata,
}
log.Infof("Running sample %d/%d: %v", i, cfg.Samples, cfg.Duration)
// TODO ingress controller warmup is needed
for _, pod := range clientPods {
wg.Add(1)
go exec(context.TODO(), &wg, tool, pod, &result)
Expand All @@ -72,6 +71,10 @@ func runBenchmark(cfg config.Config, clusterMetadata ocpmetadata.ClusterMetadata
genResultSummary(&result)
log.Infof("Summary: Rps=%.2f req/s avgLatency=%.2f μs P99Latency=%.2f μs", result.TotalAvgRps, result.AvgLatency, result.P99Latency)
benchmarkResult = append(benchmarkResult, result)
if cfg.SampleDelay != 0 {
log.Info("Sleeping for ", cfg.SampleDelay)
time.Sleep(cfg.SampleDelay)
}
}
return benchmarkResult, nil
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ func Start(uuid string, indexer *indexers.Indexer) error {
return err
}
if indexer != nil {
msg, err := (*indexer).Index(result, indexers.IndexingOpts{})
if err != nil {
return err
if !cfg.Warmup {
msg, err := (*indexer).Index(result, indexers.IndexingOpts{})
if err != nil {
return err
}
log.Info(msg)
} else {
log.Info("Warmup is enabled, skipping indexing")
}
log.Info(msg)
}
}
return nil
Expand Down

0 comments on commit bf7adc4

Please sign in to comment.