src/pocketflow/benchmark

Performance benchmarking utilities

Provides tools to measure and compare performance of nodes and flows.

Types

BenchmarkResult = object
  name*: string
  iterations*: int
  totalTimeMs*: float
  avgTimeMs*: float
  minTimeMs*: float
  maxTimeMs*: float
  stdDevMs*: float
  throughput*: float
BenchmarkSuite = ref object
  results*: seq[BenchmarkResult]

Procs

proc benchmark(suite: BenchmarkSuite; name: string; iterations: int;
               fn: proc (): Future[void] {....gcsafe.}): Future[BenchmarkResult] {.
    ...gcsafe, stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Benchmarks an async function
proc benchmarkFlow(suite: BenchmarkSuite; name: string; flow: Flow;
                   iterations: int = 100): Future[BenchmarkResult] {....gcsafe,
    stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Benchmarks a flow execution
proc benchmarkNode(suite: BenchmarkSuite; name: string; node: BaseNode;
                   iterations: int = 100): Future[BenchmarkResult] {....gcsafe,
    stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect], forbids: [].}
Benchmarks a node execution
proc compare(suite: BenchmarkSuite; baseline: string) {....raises: [], tags: [],
    forbids: [].}
Compares all benchmarks to a baseline
proc newBenchmarkSuite(): BenchmarkSuite {....raises: [], tags: [], forbids: [].}
proc printSummary(suite: BenchmarkSuite) {....raises: [], tags: [], forbids: [].}
Prints a formatted summary of all benchmarks
proc toJson(suite: BenchmarkSuite): JsonNode {....raises: [], tags: [], forbids: [].}
Converts benchmark results to JSON