qualia_cli/
benchmark_env.rs1use serde_json::json;
4
5const MEMORY_CEILING_MB: u16 = 512;
6
7fn host_class() -> &'static str {
8 #[cfg(all(target_arch = "aarch64", target_os = "macos"))]
9 {
10 return "APPLE_SILICON";
11 }
12 #[cfg(all(target_arch = "aarch64", any(target_os = "android", target_os = "ios")))]
13 {
14 return "ARM64_MOBILE";
15 }
16 #[cfg(all(
17 target_arch = "aarch64",
18 not(any(target_os = "macos", target_os = "android", target_os = "ios"))
19 ))]
20 {
21 return "ARM64_SERVER";
22 }
23 #[cfg(target_arch = "x86_64")]
24 {
25 return "X86_64_SERVER";
26 }
27 #[cfg(target_arch = "wasm32")]
28 {
29 return "WASM_BROWSER";
30 }
31 #[cfg(not(any(
32 all(target_arch = "aarch64", target_os = "macos"),
33 all(target_arch = "aarch64", any(target_os = "android", target_os = "ios")),
34 all(
35 target_arch = "aarch64",
36 not(any(target_os = "macos", target_os = "android", target_os = "ios"))
37 ),
38 target_arch = "x86_64",
39 target_arch = "wasm32",
40 )))]
41 {
42 return "UNKNOWN";
43 }
44}
45
46pub fn collect_device_manifest() -> serde_json::Value {
48 let mut sys = sysinfo::System::new_all();
49 sys.refresh_memory();
50 let ram_gb = (sys.total_memory() as f64) / (1024.0 * 1024.0 * 1024.0);
51
52 json!({
53 "host_class": host_class(),
54 "cpu_arch": std::env::consts::ARCH,
55 "os": std::env::consts::OS,
56 "cpu_logical_cores": sysinfo::System::physical_core_count(),
57 "ram_reported_gb": (ram_gb * 10.0).round() / 10.0,
58 "has_simd_wasm": false,
59 "has_npu": false
60 })
61}
62
63pub fn bench_execution_environment() -> serde_json::Value {
65 json!({
66 "runner": "qualia-cli bench",
67 "engine_version": env!("CARGO_PKG_VERSION"),
68 "memory_ceiling_mb": MEMORY_CEILING_MB,
69 "measurement_path": "in_process_microbench",
70 "topology": {
71 "mode": "single_process",
72 "worker_cells_configured": 1,
73 "worker_cells_active_during_run": 1,
74 "compute_swarm_enabled": false,
75 "cell_memory_floor_mb": MEMORY_CEILING_MB,
76 "scheduling": "serial"
77 },
78 "device_manifest": collect_device_manifest()
79 })
80}