Files
@ 36cc1fe490f7
Branch filter:
Location: CSY/reowolf/src/runtime2/tests/mod.rs - annotation
36cc1fe490f7
1.6 KiB
application/rls-services+xml
Merge branch 'feat-api-cmds-and-branching'
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
252d005a21e3 b989e88265a8 a2bfd792a202 cb4c9d11dfe6 252d005a21e3 7d01f1245b7c 7d01f1245b7c 7d01f1245b7c 665aa326769e 1b179e5f4579 665aa326769e b989e88265a8 088be7630245 088be7630245 088be7630245 c502fc0c252a c502fc0c252a 7d01f1245b7c c502fc0c252a 665aa326769e 7d01f1245b7c 7d01f1245b7c 665aa326769e c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a c502fc0c252a b989e88265a8 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a b989e88265a8 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a 7ce4d293022a | mod network_shapes;
mod api_component;
mod speculation_basic;
mod basics;
use super::*;
use crate::{PortId, ProtocolDescription};
use crate::common::Id;
use crate::protocol::eval::*;
use crate::runtime2::native::{ApplicationSyncAction};
// Generic testing constants, use when appropriate to simplify stress-testing
pub(crate) const NUM_THREADS: u32 = 3; // number of threads in runtime
pub(crate) const NUM_INSTANCES: u32 = 7; // number of test instances constructed
pub(crate) const NUM_LOOPS: u32 = 8; // number of loops within a single test (not used by all tests)
fn create_runtime(pdl: &str) -> Runtime {
let protocol = ProtocolDescription::parse(pdl.as_bytes()).expect("parse pdl");
let runtime = Runtime::new(NUM_THREADS, protocol);
return runtime;
}
fn run_test_in_runtime<F: Fn(&mut ApplicationInterface)>(pdl: &str, constructor: F) {
let protocol = ProtocolDescription::parse(pdl.as_bytes())
.expect("parse PDL");
let runtime = Runtime::new(NUM_THREADS, protocol);
let mut api = runtime.create_interface();
for _ in 0..NUM_INSTANCES {
constructor(&mut api);
}
}
pub(crate) struct TestTimer {
name: &'static str,
started: std::time::Instant
}
impl TestTimer {
pub(crate) fn new(name: &'static str) -> Self {
Self{ name, started: std::time::Instant::now() }
}
}
impl Drop for TestTimer {
fn drop(&mut self) {
let delta = std::time::Instant::now() - self.started;
let nanos = (delta.as_secs_f64() * 1_000_000.0) as u64;
let millis = nanos / 1000;
let nanos = nanos % 1000;
println!("[{}] Took {:>4}.{:03} ms", self.name, millis, nanos);
}
}
|