Skip to content

Commit

Permalink
Adding pause duration.
Browse files Browse the repository at this point in the history
  • Loading branch information
strategicpause committed Nov 1, 2023
1 parent c558daf commit ea48ada
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion command/memory/leak.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Params struct {
MaxMemoryInBytes uint64
BlockSizeInBytes uint64
StepTimeInSeconds time.Duration
PauseTimeInSeconds time.Duration
}

Expand All @@ -24,9 +25,11 @@ func memoryLeak(params *Params) error {
list[i][j] = 0
}
metrics.PrintMemory()
time.Sleep(params.PauseTimeInSeconds)
time.Sleep(params.StepTimeInSeconds)
}

fmt.Printf("Waiting for %s.\n", params.PauseTimeInSeconds.String())
time.Sleep(params.PauseTimeInSeconds)
fmt.Println("Done")

return nil
Expand Down
17 changes: 13 additions & 4 deletions command/memory/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
"github.com/urfave/cli"
)

const MaxMemoryName = "max-memory"
const BlockSizeName = "block-size"
const PauseDurationName = "pause"
const (
MaxMemoryName = "max-memory"
BlockSizeName = "block-size"
StepDurationName = "step-duration"
PauseDurationName = "pause-duration"
)

func Register() cli.Command {
return cli.Command{
Expand All @@ -32,10 +35,15 @@ func flags() []cli.Flag {
Value: "10MB",
},
cli.DurationFlag{
Name: PauseDurationName,
Name: StepDurationName,
Usage: "Time between allocations in seconds.",
Value: 1,
},
cli.DurationFlag{
Name: PauseDurationName,
Usage: "Time to wait, in seconds, after all memory has been allocated.",
Value: 0,
},
}
}

Expand All @@ -57,6 +65,7 @@ func action(ctx *cli.Context) error {
params := &Params{
MaxMemoryInBytes: uint64(maxMemory),
BlockSizeInBytes: uint64(blockSize),
StepTimeInSeconds: ctx.Duration(StepDurationName),
PauseTimeInSeconds: ctx.Duration(PauseDurationName),
}

Expand Down

0 comments on commit ea48ada

Please sign in to comment.