24 lines
574 B
Go
24 lines
574 B
Go
package executer
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type Results struct {
|
|
StepsTaken uint64 // Number of steps taken during execution.
|
|
TimeElapsed uint64 // The time (ms) taken for execution to complete.
|
|
}
|
|
|
|
func (r Results) OpsPerSecond() float32 {
|
|
return float32(r.StepsTaken) / (float32(r.TimeElapsed) / 1000)
|
|
}
|
|
|
|
func (r Results) String() string {
|
|
builder := strings.Builder{}
|
|
fmt.Fprintln(&builder, "Time Spent:", r.TimeElapsed, "ms")
|
|
fmt.Fprintln(&builder, "Steps:", r.StepsTaken)
|
|
fmt.Fprintln(&builder, "Speed:", r.OpsPerSecond(), "ops")
|
|
return builder.String()
|
|
}
|