#![allow( clippy::large_enum_variant, clippy::type_complexity, clippy::too_many_arguments )] use criterion::{black_box, criterion_group, criterion_main, Criterion}; use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send}; use mpstthree::generate; use mpstthree::role::end::RoleEnd; use std::error::Error; generate!( "rec_and_cancel", MeshedChannels, Constellation, Layout, Script ); // Payload types struct GetCurrentState; struct DocumentLoading; struct WebFontLoaded; struct GetWebPageLoadState; struct OutstandingWebFonts; // Binary types // Constellation thread type CtoL = Send>; type CtoS = Send>; //Layout thread type LtoC = Recv>; type LtoS = Send; // Script thread type StoC = Recv>; type StoL = Recv; // Orderings type OrderingC = RoleScript>>>; type OrderingL = RoleScript>>; type OrderingS = RoleConstellation>>; // MeshedChannels type EndpointC = MeshedChannels; type EndpointL = MeshedChannels; type EndpointS = MeshedChannels; // Functions ///////////////////////// // Functions related to endpoints fn endpoint_c(s: EndpointC) -> Result<(), Box> { let s = s.send(GetCurrentState {})?; let (_, s) = s.recv()?; // To "process" the information let s = s.send(GetWebPageLoadState {})?; let (_, s) = s.recv()?; s.close() } ///////////////////////// fn endpoint_l(s: EndpointL) -> Result<(), Box> { let s = s.send(WebFontLoaded {})?; let (_, s) = s.recv()?; let s = s.send(OutstandingWebFonts {})?; s.close() } ///////////////////////// fn endpoint_s(s: EndpointS) -> Result<(), Box> { let (_, s) = s.recv()?; let s = s.send(DocumentLoading {})?; let (_, s) = s.recv()?; 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("Servo AMPST", |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 }