summaryrefslogtreecommitdiff
path: root/internal/cpu/types.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-04 23:28:48 +0300
committerPaul Buetow <paul@buetow.org>2026-05-04 23:28:48 +0300
commitd0a5493e9710f4b515ad5825aeee3c0102d03ee7 (patch)
tree8f8ddcbf96beb517252ce525060382f22b83fa6a /internal/cpu/types.go
parent2f09915d3da7a23574e1a90fa70eb1af1cdf830a (diff)
renamemain
Diffstat (limited to 'internal/cpu/types.go')
-rw-r--r--internal/cpu/types.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/internal/cpu/types.go b/internal/cpu/types.go
index 58da0a9..45f6ff5 100644
--- a/internal/cpu/types.go
+++ b/internal/cpu/types.go
@@ -1,7 +1,10 @@
// Package cpu provides CPU stress testing with multiple algorithms and chaos modes.
package cpu
-import "time"
+import (
+ "runtime"
+ "time"
+)
// types.go defines the configuration types and mode constants for CPU stress testing.
@@ -18,7 +21,6 @@ const (
ModeEncrypt Mode = "encrypt"
ModeSort Mode = "sort"
ModeBusy Mode = "busy"
- ModeRandom Mode = "random"
)
var allModes = []Mode{
@@ -42,4 +44,24 @@ type Config struct {
ChaosInterval time.Duration
IntensityMin int
IntensityMax int
+ MinCPUs int
+ MaxCPUs int
+}
+
+func (c *Config) normalize() {
+ if c.MinCPUs <= 0 {
+ c.MinCPUs = 1
+ }
+ if c.MaxCPUs <= 0 {
+ c.MaxCPUs = runtime.NumCPU()
+ }
+ if c.MinCPUs > runtime.NumCPU() {
+ c.MinCPUs = runtime.NumCPU()
+ }
+ if c.MaxCPUs > runtime.NumCPU() {
+ c.MaxCPUs = runtime.NumCPU()
+ }
+ if c.MinCPUs > c.MaxCPUs {
+ c.MinCPUs, c.MaxCPUs = c.MaxCPUs, c.MinCPUs
+ }
}