Struct seec_channel::util::RunResult
source · pub struct RunResult {
pub meta: Metadata,
pub communication_bytes: IndexMap<Phase, CountPair>,
pub time_ms: IndexMap<Phase, u128>,
}
Fields§
§meta: Metadata
§communication_bytes: IndexMap<Phase, CountPair>
§time_ms: IndexMap<Phase, u128>
Implementations§
source§impl RunResult
impl RunResult
sourcepub fn add_metadata<V: Serialize + Debug + Send + 'static>(
&mut self,
key: &str,
value: V
)
pub fn add_metadata<V: Serialize + Debug + Send + 'static>( &mut self, key: &str, value: V )
Add any metadata to the { "meta": { "custom": { .. }, .. } }
map inside the result.
The value can be of any type that implements Serialize
, Debug
and is `‘static’.
§Example
let statistics = Statistics::default();
let mut run_res = statistics.into_run_result();
run_res.add_metadata("Description", "Lorem Ipsum");
run_res.add_metadata("other-data", vec![1, 2, 3]);
Examples found in repository?
crates/seec/examples/sha256.rs (line 114)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
async fn main() -> Result<()> {
let _guard = init_tracing()?;
let args = Args::parse();
let circuit: ExecutableCircuit<bool, BooleanGate, u32> = ExecutableCircuit::DynLayers(
BaseCircuit::load_bristol(args.circuit, Load::Circuit)?.into(),
);
let (mut sender, bytes_written, mut receiver, bytes_read) = match args.id {
0 => seec_channel::tcp::listen(args.server).await?,
1 => seec_channel::tcp::connect(args.server).await?,
illegal => anyhow::bail!("Illegal party id {illegal}. Must be 0 or 1."),
};
// Initialize the communication statistics tracker with the counters for the main channel
let mut comm_stats = Statistics::new(bytes_written, bytes_read).without_unaccounted(true);
let (mut sender, mut receiver) =
sub_channels_for!(&mut sender, &mut receiver, 8, Message<BooleanGmw>).await?;
let mut executor: Executor<BooleanGmw, _> = if let Some(addr) = args.mt_provider {
let (mt_sender, bytes_written, mt_receiver, bytes_read) =
seec_channel::tcp::connect(addr).await?;
// Set the counters for the helper channel
comm_stats.set_helper(bytes_written, bytes_read);
let mt_provider = TrustedMTProviderClient::new("unique-id".into(), mt_sender, mt_receiver);
// As the MTs are generated when the Executor is created, we record the communication
// with the `record_helper` method and a custom category
comm_stats
.record_helper(
Phase::Custom("Helper-Mts".into()),
Executor::new(&circuit, args.id, mt_provider),
)
.await?
} else {
let mt_provider = InsecureMTProvider::default();
comm_stats
.record(
Phase::FunctionDependentSetup,
Executor::new(&circuit, args.id, mt_provider),
)
.await?
};
let input = BitVec::repeat(false, 768);
let _out = comm_stats
.record(
Phase::Online,
executor.execute(Input::Scalar(input), &mut sender, &mut receiver),
)
.await?;
// Depending on whether a --stats file is set, create a file writer or stdout
let mut writer: Box<dyn Write> = match args.stats {
Some(path) => {
let file = File::create(path)?;
Box::new(file)
}
None => Box::new(stdout()),
};
// serde_json is used to write the statistics in json format. `.csv` is currently not
// supported.
let mut res = comm_stats.into_run_result();
res.add_metadata("circuit", "sha256.rs");
serde_json::to_writer_pretty(&mut writer, &res)?;
writeln!(writer)?;
Ok(())
}
pub fn total_bytes_sent(&self) -> usize
pub fn total_bytes_recv(&self) -> usize
pub fn setup_ms(&self) -> u128
pub fn online_ms(&self) -> u128
Trait Implementations§
source§impl<'de> Deserialize<'de> for RunResult
impl<'de> Deserialize<'de> for RunResult
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RunResult
impl !RefUnwindSafe for RunResult
impl Send for RunResult
impl !Sync for RunResult
impl Unpin for RunResult
impl !UnwindSafe for RunResult
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more