///|
pub struct BenchmarkMeasurement {
name : String
operations : Int
token_count : Int
input_bytes : Int
output_bytes : Int
elapsed_units : UInt64
} derive(Debug, Eq)
///|
pub struct BenchmarkReport {
toolchain : String
measurements : Array[BenchmarkMeasurement]
} derive(Debug, Eq)
///|
pub fn BenchmarkReport::to_markdown(self : BenchmarkReport) -> String {
let lines : Array[String] = [
"# Benchmark",
"",
"Toolchain: `" + self.toolchain + "`",
"",
"Elapsed values are measured clock units from `moonbitlang/core/env.now`; repeat the command on the target machine for comparable results.",
"",
"| Scenario | Operations | Tokens | Input bytes | Output bytes | Elapsed units |",
"| --- | ---: | ---: | ---: | ---: | ---: |",
]
for measurement in self.measurements {
lines.push(
"| " +
measurement.name +
" | " +
measurement.operations.to_string() +
" | " +
measurement.token_count.to_string() +
" | " +
measurement.input_bytes.to_string() +
" | " +
measurement.output_bytes.to_string() +
" | " +
measurement.elapsed_units.to_string() +
" |",
)
}
lines.join("\n") + "\n"
}