Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Implement GC-managed random generators, next/nextf intrinsics, bounded ranges and deterministic conformance coverage. Publish the runtime contract and producer guidance. Give coverage domains at least five percentage points of measured headroom while preserving sufficient floors. Record local qualification: make ci-domains passes with 939 tests and all domain gates green.
50 lines
1.7 KiB
Rust
50 lines
1.7 KiB
Rust
//! Local host timing only; these measurements never define guest cycles.
|
|
use prometeu_bytecode::Value;
|
|
use prometeu_vm::{HostContext, lookup_intrinsic_by_id};
|
|
use std::hint::black_box;
|
|
use std::time::Instant;
|
|
fn main() {
|
|
let iterations: u32 =
|
|
std::env::args().nth(1).unwrap_or_else(|| "20000".into()).parse().unwrap();
|
|
for (id, args) in [
|
|
(0x3010, vec![Value::Float(2.)]),
|
|
(0x3011, vec![Value::Float(f64::from_bits(0x6974e718d7d7625a))]),
|
|
(0x3012, vec![Value::Float(f64::from_bits(0x7fefffffffffffff))]),
|
|
(0x3013, vec![Value::Float(1.), Value::Float(3.)]),
|
|
(0x1000, vec![Value::Float(1.), Value::Float(2.), Value::Float(3.), Value::Float(4.)]),
|
|
(0x1001, vec![Value::Float(1e200), Value::Float(1e200)]),
|
|
] {
|
|
let m = lookup_intrinsic_by_id(id).unwrap();
|
|
let mut ctx = HostContext::new(None);
|
|
for _ in 0..100 {
|
|
black_box(
|
|
(m.implementation.host_callback().expect("host intrinsic"))(
|
|
black_box(&args),
|
|
&mut ctx,
|
|
)
|
|
.unwrap(),
|
|
);
|
|
}
|
|
let start = Instant::now();
|
|
for _ in 0..iterations {
|
|
black_box(
|
|
(m.implementation.host_callback().expect("host intrinsic"))(
|
|
black_box(&args),
|
|
&mut ctx,
|
|
)
|
|
.unwrap(),
|
|
);
|
|
}
|
|
let elapsed = start.elapsed().as_nanos();
|
|
println!(
|
|
"{}.{} iterations={} total_ns={} ns_per_call={:.2} virtual_cycles={}",
|
|
m.owner,
|
|
m.name,
|
|
iterations,
|
|
elapsed,
|
|
elapsed as f64 / f64::from(iterations),
|
|
m.cost_cycles
|
|
);
|
|
}
|
|
}
|