summaryrefslogtreecommitdiff
path: root/internal/ior.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-29 18:19:06 +0200
committerPaul Buetow <paul@buetow.org>2025-03-29 18:19:06 +0200
commitb8ac7c88b203ba5475cbca63669ce654c2ed49ea (patch)
tree3fc6d2539ced1d4012f9bf0fe69d4d191e2a5049 /internal/ior.go
parentdc5c405f6afb9fc59ba73e7dbc7cd3564983ae6e (diff)
flags is now a singleton
Diffstat (limited to 'internal/ior.go')
-rw-r--r--internal/ior.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/ior.go b/internal/ior.go
index 7bf96bc..3d6fd1e 100644
--- a/internal/ior.go
+++ b/internal/ior.go
@@ -19,9 +19,9 @@ import (
// TODO: Generally, write unit tests
// TODO: Integration tests, write C or Cgo code to simulate I/O?
-func attachTracepoints(flags flags.Flags, bpfModule *bpf.Module) error {
+func attachTracepoints(bpfModule *bpf.Module) error {
for _, name := range tracepoints.List {
- if !flags.ShouldIAttachTracepoint(name) {
+ if !flags.Get().ShouldIAttachTracepoint(name) {
continue
}
fmt.Println("Attaching tracepoint", name)
@@ -43,18 +43,18 @@ func attachTracepoints(flags flags.Flags, bpfModule *bpf.Module) error {
return nil
}
-func Run(flags flags.Flags) {
+func Run() {
bpfModule, err := bpf.NewModuleFromFile("ior.bpf.o")
if err != nil {
panic(err)
}
defer bpfModule.Close()
- if err := flags.ResizeBPFMaps(bpfModule); err != nil {
+ if err := flags.Get().ResizeBPFMaps(bpfModule); err != nil {
panic(err)
}
- if err := flags.SetBPF(bpfModule); err != nil {
+ if err := flags.Get().SetBPF(bpfModule); err != nil {
panic(err)
}
@@ -62,7 +62,7 @@ func Run(flags flags.Flags) {
panic(err)
}
- if err := attachTracepoints(flags, bpfModule); err != nil {
+ if err := attachTracepoints(bpfModule); err != nil {
panic(err)
}
@@ -76,7 +76,7 @@ func Run(flags flags.Flags) {
pprofDone := make(chan struct{})
var cpuProfile, memProfile *os.File
- if flags.PprofEnable {
+ if flags.Get().PprofEnable {
if cpuProfile, err = os.Create("ior.cpuprofile"); err != nil {
panic(err)
}
@@ -88,8 +88,8 @@ func Run(flags flags.Flags) {
close(pprofDone)
}
- loop := newEventLoop(flags)
- duration := time.Duration(flags.Duration) * time.Second
+ loop := newEventLoop()
+ duration := time.Duration(flags.Get().Duration) * time.Second
fmt.Println("Probing for", duration)
ctx, cancel := context.WithTimeout(context.Background(), duration)
@@ -105,7 +105,7 @@ func Run(flags flags.Flags) {
go func() {
<-ctx.Done()
fmt.Println(loop.stats())
- if flags.PprofEnable {
+ if flags.Get().PprofEnable {
fmt.Println("Stoppig profiling, writing ior.cpuprofile and ior.memprofile")
pprof.StopCPUProfile()
pprof.WriteHeapProfile(memProfile)