kevo/pkg/grpc/transport/benchmark.go
Jeremy Tregunna a0a1c0512f
All checks were successful
Go Tests / Run Tests (1.24.2) (push) Successful in 9m50s
chore: formatting
2025-04-22 14:09:54 -06:00

60 lines
1.4 KiB
Go

package transport
import (
"context"
"time"
)
// BenchmarkOptions defines the options for gRPC benchmarking
type BenchmarkOptions struct {
Address string
Connections int
Iterations int
KeySize int
ValueSize int
Parallelism int
UseTLS bool
TLSConfig *TLSConfig
}
// BenchmarkResult holds the results of a benchmark run
type BenchmarkResult struct {
Operation string
TotalTime time.Duration
RequestsPerSec float64
AvgLatency time.Duration
MinLatency time.Duration
MaxLatency time.Duration
P90Latency time.Duration
P99Latency time.Duration
TotalBytes int64
BytesPerSecond float64
ErrorRate float64
TotalOperations int
FailedOps int
}
// NOTE: This is a stub implementation
// A proper benchmark requires the full client implementation
// which will be completed in a later phase
func Benchmark(ctx context.Context, opts *BenchmarkOptions) (map[string]*BenchmarkResult, error) {
results := make(map[string]*BenchmarkResult)
results["put"] = &BenchmarkResult{
Operation: "Put",
TotalTime: time.Second,
RequestsPerSec: 1000.0,
}
return results, nil
}
// sortDurations sorts a slice of durations in ascending order
func sortDurations(durations []time.Duration) {
for i := 0; i < len(durations); i++ {
for j := i + 1; j < len(durations); j++ {
if durations[i] > durations[j] {
durations[i], durations[j] = durations[j], durations[i]
}
}
}
}