///|
/// Benchmark result suitable for committing as a reproducible local report.
pub(all) struct BenchmarkResult {
name : String
iterations : Int
output_size : Int
checksum : Int
} derive(Eq, Debug, ToJson)
///|
fn checksum(text : String) -> Int {
let mut value = 0
for code in text.to_array() {
value = (value * 31 + code.to_int()) % 1000000007
}
value
}
///|
pub fn benchmark_scene(
iterations : Int,
width : Double,
height : Double,
columns : Int,
rows : Int,
) -> BenchmarkResult {
let mut output_size = 0
let mut digest = 0
for i in 0.. BenchmarkResult {
let sampler = ValueNoise::new(0.05, 42U)
let mut total = 0.0
for iteration in 0.. BenchmarkResult {
let mut output_size = 0
let mut digest = 0
for index in 0.. BenchmarkResult {
let mut output_size = 0
let mut digest = 0
for index in 0.. String {
"name,iterations,output_size,checksum\n\{scene.name},\{scene.iterations},\{scene.output_size},\{scene.checksum}\n\{noise.name},\{noise.iterations},\{noise.output_size},\{noise.checksum}\n"
}
///|
/// Formats the showcase's extended benchmark set.
pub fn benchmark_report_extended(
scene : BenchmarkResult,
noise : BenchmarkResult,
pipeline : BenchmarkResult,
) -> String {
benchmark_report(scene, noise) +
"\{pipeline.name},\{pipeline.iterations},\{pipeline.output_size},\{pipeline.checksum}\n"
}
///|
pub fn benchmark_report_full(
scene : BenchmarkResult,
noise : BenchmarkResult,
pipeline : BenchmarkResult,
production : BenchmarkResult,
) -> String {
benchmark_report_extended(scene, noise, pipeline) +
"\{production.name},\{production.iterations},\{production.output_size},\{production.checksum}\n"
}