#![allow( clippy::type_complexity, clippy::too_many_arguments, clippy::large_enum_variant )] use criterion::{black_box, criterion_group, criterion_main, Criterion}; use mpstthree::binary::struct_trait::end::End; use mpstthree::binary_atmp::struct_trait::{recv::RecvTimed, send::SendTimed}; use mpstthree::generate_atmp; use mpstthree::role::end::RoleEnd; use std::collections::HashMap; use std::error::Error; use std::time::Instant; generate_atmp!(MeshedChannels, Constellation, Layout, Script); // Payload types struct GetCurrentState; struct DocumentLoading; struct WebFontLoaded; struct GetWebPageLoadState; struct OutstandingWebFonts; // Binary types // Constellation thread type CtoL = SendTimed< GetWebPageLoadState, 'a', 0, true, 10, true, ' ', RecvTimed, >; type CtoS = SendTimed< GetCurrentState, 'a', 0, true, 10, true, ' ', RecvTimed, >; //Layout thread type LtoC = RecvTimed< GetWebPageLoadState, 'a', 0, true, 10, true, ' ', SendTimed, >; type LtoS = SendTimed; // Script thread type StoC = RecvTimed< GetCurrentState, 'a', 0, true, 10, true, ' ', SendTimed, >; type StoL = RecvTimed; // Orderings type OrderingC = RoleScript>>>; type OrderingL = RoleScript>>; type OrderingS = RoleConstellation>>; // MeshedChannels type EndpointC = MeshedChannels; type EndpointL = MeshedChannels; type EndpointS = MeshedChannels; ///////////////////////// // Functions related to endpoints fn endpoint_c(s: EndpointC, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); let s = s.send(GetCurrentState {}, all_clocks)?; let (_, s) = s.recv(all_clocks)?; // To "process" the information let s = s.send(GetWebPageLoadState {}, all_clocks)?; let (_, s) = s.recv(all_clocks)?; s.close() } ///////////////////////// fn endpoint_l(s: EndpointL, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); let s = s.send(WebFontLoaded {}, all_clocks)?; let (_, s) = s.recv(all_clocks)?; let s = s.send(OutstandingWebFonts {}, all_clocks)?; s.close() } ///////////////////////// fn endpoint_s(s: EndpointS, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); let (_, s) = s.recv(all_clocks)?; let s = s.send(DocumentLoading {}, all_clocks)?; let (_, s) = s.recv(all_clocks)?; s.close() } //////////////////////////////////////// fn aux() { let (thread_c, thread_l, thread_s) = fork_mpst( black_box(endpoint_c), black_box(endpoint_l), black_box(endpoint_s), ); thread_c.join().unwrap(); thread_l.join().unwrap(); thread_s.join().unwrap(); } ///////////////////////// pub fn servo(c: &mut Criterion) { c.bench_function("ATMP Servo", |b| b.iter(aux)); } ///////////////////////// criterion_group! { name = bench; config = Criterion::default().significance_level(0.05).without_plots().sample_size(100000); targets = servo, } criterion_main! { bench }