feat: meaningful comments for internal packages

This commit is contained in:
2025-12-29 20:39:43 -05:00
parent aabe92f2dc
commit 05cd8bc4f3
7 changed files with 25 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
// Package "statistics" provides a way to observer reduction speed during
// execution.
package statistics
import (
@@ -5,15 +7,18 @@ import (
"strings"
)
// Statistics for a specific reduction.
type Results struct {
StepsTaken uint64 // Number of steps taken during execution.
TimeElapsed uint64 // The time (ms) taken for execution to complete.
}
// Returns the average number of operations per second of the execution.
func (r Results) OpsPerSecond() float32 {
return float32(r.StepsTaken) / (float32(r.TimeElapsed) / 1000)
}
// Format the results as a string.
func (r Results) String() string {
builder := strings.Builder{}
fmt.Fprintln(&builder, "Time Spent:", r.TimeElapsed, "ms")

View File

@@ -6,11 +6,13 @@ import (
"time"
)
// An observer, to track reduction performance.
type Tracker struct {
start time.Time
steps uint64
}
// Create a new reduction performance tracker.
func Track() *Tracker {
return &Tracker{}
}