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

source

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(())
}
source

pub fn total_bytes_sent(&self) -> usize

source

pub fn total_bytes_recv(&self) -> usize

source

pub fn setup_ms(&self) -> u128

source

pub fn online_ms(&self) -> u128

source

pub fn mean(data: &[Self]) -> Self

Calculate mean, loses metadata information.

Trait Implementations§

source§

impl Clone for RunResult

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RunResult

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RunResult

source§

fn default() -> RunResult

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for RunResult

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for RunResult

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer ) -> Result<(), ErrorImpl>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> RemoteSend for T
where T: Send + Serialize + DeserializeOwned + 'static,