Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
38 lines
1.4 KiB
Rust
38 lines
1.4 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)(black_box(&args), &mut ctx).unwrap());
|
|
}
|
|
let start = Instant::now();
|
|
for _ in 0..iterations {
|
|
black_box((m.implementation)(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
|
|
);
|
|
}
|
|
}
|