(
module: &BenchmarkModule,
cli_path: &Path,
config_path: &Path,
server_url: &str,
)
| 67 | } |
| 68 | |
| 69 | fn run_module_benchmark( |
| 70 | module: &BenchmarkModule, |
| 71 | cli_path: &Path, |
| 72 | config_path: &Path, |
| 73 | server_url: &str, |
| 74 | ) -> Result<BenchmarkResult> { |
| 75 | eprintln!( |
| 76 | "Running keynote benchmark against {} module ({})...", |
| 77 | module.label, module.module_dir |
| 78 | ); |
| 79 | |
| 80 | publish_module(module, cli_path, config_path, server_url)?; |
| 81 | generate_module_bindings(module, cli_path, config_path)?; |
| 82 | seed_accounts(cli_path, config_path, server_url)?; |
| 83 | let runs_dir = tempfile::tempdir().context("failed to create temporary benchmark runs directory")?; |
| 84 | let transfer_fuel_before = transfer_fuel_total(server_url)?; |
| 85 | run_benchmark(module, server_url, runs_dir.path())?; |
| 86 | let transfer_fuel_after = transfer_fuel_total(server_url)?; |
| 87 | let transfer_fuel_total = transfer_fuel_after - transfer_fuel_before; |
| 88 | ensure!( |
| 89 | transfer_fuel_total > 0.0, |
| 90 | "{} keynote benchmark did not record any fuel for the {TRANSFER_REDUCER} reducer", |
| 91 | module.label |
| 92 | ); |
| 93 | |
| 94 | let result_path = find_result_json(runs_dir.path())?; |
| 95 | let result_json = fs::read_to_string(&result_path) |
| 96 | .with_context(|| format!("failed to read benchmark result {}", result_path.display()))?; |
| 97 | let tps = result_tps(&result_json)?; |
| 98 | |
| 99 | if tps < module.min_tps { |
| 100 | eprintln!( |
| 101 | "Keynote perf regression for {} module: throughput {tps:.0} TPS < {:.0} TPS\n\nResult JSON:\n{}", |
| 102 | module.label, module.min_tps, result_json |
| 103 | ); |
| 104 | bail!( |
| 105 | "keynote benchmark throughput for {} module is below threshold", |
| 106 | module.label |
| 107 | ); |
| 108 | } |
| 109 | |
| 110 | println!( |
| 111 | "Keynote perf check passed for {} module: throughput {tps:.0} TPS >= {:.0} TPS; \ |
| 112 | {TRANSFER_REDUCER} fuel total {transfer_fuel_total:.0} ({})", |
| 113 | module.label, |
| 114 | module.min_tps, |
| 115 | result_path.display() |
| 116 | ); |
| 117 | Ok(BenchmarkResult { |
| 118 | label: module.label, |
| 119 | transfer_fuel_total, |
| 120 | }) |
| 121 | } |
| 122 | |
| 123 | fn publish_module(module: &BenchmarkModule, cli_path: &Path, config_path: &Path, server_url: &str) -> Result<()> { |
| 124 | let label = format!("spacetime publish keynote {} module", module.label); |
no test coverage detected
searching dependent graphs…