///|
pub struct BenchmarkResult {
iterations : Int
reports : Int
markdown_bytes : Int
html_bytes : Int
json_bytes : Int
} derive(Debug, Eq)
///|
pub fn benchmark_exports(
reports : Array[ChemReport],
iterations : Int,
) -> BenchmarkResult {
let safe_iterations = if iterations < 0 { 0 } else { iterations }
let mut markdown_bytes = 0
let mut html_bytes = 0
let mut json_bytes = 0
for _ in 0.. Int {
self.markdown_bytes + self.html_bytes + self.json_bytes
}
///|
pub fn BenchmarkResult::average_bytes(self : BenchmarkResult) -> Float {
if self.reports == 0 {
0.0
} else {
Float::from_int(self.total_bytes()) / Float::from_int(self.reports)
}
}
///|
pub fn BenchmarkResult::to_markdown(self : BenchmarkResult) -> String {
"| Format | Bytes |\n| --- | ---: |\n| Markdown | \{self.markdown_bytes} |\n| HTML | \{self.html_bytes} |\n| JSON | \{self.json_bytes} |\n| Total | \{self.total_bytes()} |"
}