Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's on-box pages, and what it costs. What works: - schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs); - src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so the unified sidebar, ordering and surface filtering come from the schema rather than from hand-written HTML; - the render uses the shared bf- design tokens, the same ones the rest of the suite uses. Size, measured rather than assumed (armv7, release, stripped): ui-baseline 323 KiB (maud + serde_json, no flare-ui) ui-spike 771 KiB (flare-ui + wschema + sha2) marginal 448 KiB Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in flare-ui/flare-ui.lock (a partial archive does not compile, since the crate include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo directory source with the new registry dependencies (maud, sha2, typenum, digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build still works offline. third-party/README.md records how to re-pin.
92 lines
2.8 KiB
Rust
92 lines
2.8 KiB
Rust
use crate::error::Result;
|
|
use crate::measurement::ValueFormatter;
|
|
use crate::report::{BenchmarkId, MeasurementData, Report, ReportContext};
|
|
use crate::Throughput;
|
|
use csv::Writer;
|
|
use std::io::Write;
|
|
use std::path::Path;
|
|
|
|
#[derive(Serialize)]
|
|
struct CsvRow<'a> {
|
|
group: &'a str,
|
|
function: Option<&'a str>,
|
|
value: Option<&'a str>,
|
|
throughput_num: Option<&'a str>,
|
|
throughput_type: Option<&'a str>,
|
|
sample_measured_value: f64,
|
|
unit: &'static str,
|
|
iteration_count: u64,
|
|
}
|
|
|
|
struct CsvReportWriter<W: Write> {
|
|
writer: Writer<W>,
|
|
}
|
|
impl<W: Write> CsvReportWriter<W> {
|
|
fn write_data(
|
|
&mut self,
|
|
id: &BenchmarkId,
|
|
data: &MeasurementData<'_>,
|
|
formatter: &dyn ValueFormatter,
|
|
) -> Result<()> {
|
|
let mut data_scaled: Vec<f64> = data.sample_times().as_ref().into();
|
|
let unit = formatter.scale_for_machines(&mut data_scaled);
|
|
let group = id.group_id.as_str();
|
|
let function = id.function_id.as_deref();
|
|
let value = id.value_str.as_deref();
|
|
let (throughput_num, throughput_type) = match id.throughput {
|
|
Some(Throughput::Bytes(bytes)) => (Some(format!("{}", bytes)), Some("bytes")),
|
|
Some(Throughput::BytesDecimal(bytes)) => (Some(format!("{}", bytes)), Some("bytes")),
|
|
Some(Throughput::Elements(elems)) => (Some(format!("{}", elems)), Some("elements")),
|
|
None => (None, None),
|
|
};
|
|
let throughput_num = throughput_num.as_deref();
|
|
|
|
for (count, measured_value) in data.iter_counts().iter().zip(data_scaled.into_iter()) {
|
|
let row = CsvRow {
|
|
group,
|
|
function,
|
|
value,
|
|
throughput_num,
|
|
throughput_type,
|
|
sample_measured_value: measured_value,
|
|
unit,
|
|
iteration_count: (*count) as u64,
|
|
};
|
|
self.writer.serialize(row)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub struct FileCsvReport;
|
|
impl FileCsvReport {
|
|
fn write_file(
|
|
&self,
|
|
path: &Path,
|
|
id: &BenchmarkId,
|
|
measurements: &MeasurementData<'_>,
|
|
formatter: &dyn ValueFormatter,
|
|
) -> Result<()> {
|
|
let writer = Writer::from_path(path)?;
|
|
let mut writer = CsvReportWriter { writer };
|
|
writer.write_data(id, measurements, formatter)?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl Report for FileCsvReport {
|
|
fn measurement_complete(
|
|
&self,
|
|
id: &BenchmarkId,
|
|
context: &ReportContext,
|
|
measurements: &MeasurementData<'_>,
|
|
formatter: &dyn ValueFormatter,
|
|
) {
|
|
let mut path = context.output_directory.clone();
|
|
path.push(id.as_directory_name());
|
|
path.push("new");
|
|
path.push("raw.csv");
|
|
log_if_err!(self.write_file(&path, id, measurements, formatter));
|
|
}
|
|
}
|