MOTION  0.01
Framework for mixed-protocol multi-party computation
analysis.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019-2021 Lennart Braun, Arianne Roselina Prananto
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include <boost/accumulators/accumulators.hpp>
26 #include <boost/accumulators/statistics/count.hpp>
27 #include <boost/accumulators/statistics/mean.hpp>
28 #include <boost/accumulators/statistics/median.hpp>
29 #include <boost/accumulators/statistics/stats.hpp>
30 #include <boost/accumulators/statistics/variance.hpp>
31 #include <boost/json.hpp>
32 #include <list>
33 #include "run_time_statistics.h"
34 
36 
37 struct TransportStatistics;
38 
39 } // namespace encrypto::motion::communication
40 
41 namespace encrypto::motion {
42 
44  public:
45  using ClockType = std::chrono::steady_clock;
46  using Duration = ClockType::duration;
47  using Resolution = std::milli;
48  using AccumulatorType = boost::accumulators::accumulator_set<
49  double,
50  boost::accumulators::stats<boost::accumulators::tag::mean, boost::accumulators::tag::median,
51  boost::accumulators::tag::lazy_variance>>;
52 
53  void Add(const RunTimeStatistics& statistics);
54 
55  std::string PrintHumanReadable() const;
56 
57  boost::json::object ToJson() const;
58 
59  private:
60  std::size_t count_ = 0;
61  std::array<AccumulatorType, static_cast<std::size_t>(RunTimeStatistics::StatisticsId::kMax) + 1>
62  accumulators_;
63 };
64 
66  public:
67  using AccumulatorType = boost::accumulators::accumulator_set<
68  std::size_t,
69  boost::accumulators::stats<boost::accumulators::tag::mean, boost::accumulators::tag::sum>>;
70 
71  static constexpr std::size_t kIdxNumberOfMessagesSent = 0;
72  static constexpr std::size_t kIdxNumberOfMessagesReceived = 1;
73  static constexpr std::size_t kIdxNumberOfBytesSent = 2;
74  static constexpr std::size_t kIdxNumberOfBytesReceived = 3;
75 
76  void Add(const communication::TransportStatistics& statistics);
77 
78  void Add(const std::vector<communication::TransportStatistics>& statistics);
79 
80  std::string PrintHumanReadable() const;
81 
82  boost::json::object ToJson() const;
83 
84  private:
85  std::size_t count_ = 0;
86  std::array<AccumulatorType, 4> accumulators_;
87 };
88 
89 std::string PrintStatistics(const std::string& experiment_name, const AccumulatedRunTimeStatistics&,
91 
92 } // namespace encrypto::motion
encrypto::motion::RunTimeStatistics::TimePointPair
std::pair< TimePoint, TimePoint > TimePointPair
Definition: run_time_statistics.h:35
encrypto::motion::AccumulatedCommunicationStatistics::kIdxNumberOfMessagesSent
static constexpr std::size_t kIdxNumberOfMessagesSent
Definition: analysis.h:71
encrypto::motion::AccumulatedRunTimeStatistics::ClockType
std::chrono::steady_clock ClockType
Definition: analysis.h:45
encrypto::motion::AccumulatedCommunicationStatistics::Add
void Add(const communication::TransportStatistics &statistics)
Definition: analysis.cpp:125
encrypto::motion::communication::TransportStatistics::number_of_messages_sent
std::size_t number_of_messages_sent
Definition: transport.h:33
analysis.h
encrypto::motion::AccumulatedCommunicationStatistics::kIdxNumberOfMessagesReceived
static constexpr std::size_t kIdxNumberOfMessagesReceived
Definition: analysis.h:72
encrypto::motion::AccumulatedCommunicationStatistics::kIdxNumberOfBytesSent
static constexpr std::size_t kIdxNumberOfBytesSent
Definition: analysis.h:73
encrypto::motion::AccumulatedRunTimeStatistics
Definition: analysis.h:43
encrypto::motion::GetUsername
std::string GetUsername()
Definition: runtime_info.cpp:90
encrypto::motion::RunTimeStatistics::StatisticsId::kSbSetup
@ kSbSetup
encrypto::motion::AccumulatedRunTimeStatistics::PrintHumanReadable
std::string PrintHumanReadable() const
Definition: analysis.cpp:72
encrypto::motion::AccumulatedRunTimeStatistics::ToJson
boost::json::object ToJson() const
Definition: analysis.cpp:102
encrypto::motion::FormatLine
static std::string FormatLine(std::string name, std::string unit, AccumulatedRunTimeStatistics::AccumulatorType accumulator, std::size_t field_width)
Definition: analysis.cpp:58
encrypto::motion::At
static C::value_type At(const C &container, RunTimeStatistics::StatisticsId id)
Definition: analysis.cpp:52
version.h
encrypto::motion::communication::TransportStatistics::number_of_messages_received
std::size_t number_of_messages_received
Definition: transport.h:34
encrypto::motion::RunTimeStatistics::StatisticsId::kMax
@ kMax
encrypto::motion::RunTimeStatistics::StatisticsId::kOtExtensionSetup
@ kOtExtensionSetup
transport.h
encrypto::motion::RunTimeStatistics::StatisticsId::kSpPresetup
@ kSpPresetup
encrypto::motion::RunTimeStatistics::StatisticsId::kEvaluate
@ kEvaluate
encrypto::motion::AccumulatedCommunicationStatistics::kIdxNumberOfBytesReceived
static constexpr std::size_t kIdxNumberOfBytesReceived
Definition: analysis.h:74
encrypto::motion::RunTimeStatistics::StatisticsId::kMtSetup
@ kMtSetup
encrypto::motion::GetHostname
std::string GetHostname()
Definition: runtime_info.cpp:75
encrypto::motion::RunTimeStatistics::StatisticsId::kPreprocessing
@ kPreprocessing
encrypto::motion::RunTimeStatistics::StatisticsId::kGatesOnline
@ kGatesOnline
encrypto::motion::GetGitVersion
const char * GetGitVersion()
encrypto::motion::RunTimeStatistics::StatisticsId::kBaseOts
@ kBaseOts
encrypto::motion::GetCmdLine
std::string GetCmdLine()
Definition: runtime_info.cpp:46
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::AccumulatedRunTimeStatistics::Resolution
std::milli Resolution
Definition: analysis.h:47
encrypto::motion::ComputeDuration
static double ComputeDuration(const RunTimeStatistics::TimePointPair &tpp)
Definition: analysis.cpp:37
encrypto::motion::RunTimeStatistics::StatisticsId::kMtPresetup
@ kMtPresetup
encrypto::motion::AccumulatedCommunicationStatistics::AccumulatorType
boost::accumulators::accumulator_set< std::size_t, boost::accumulators::stats< boost::accumulators::tag::mean, boost::accumulators::tag::sum > > AccumulatorType
Definition: analysis.h:69
encrypto::motion::communication::TransportStatistics::number_of_bytes_received
std::size_t number_of_bytes_received
Definition: transport.h:36
encrypto::motion::RunTimeStatistics
Definition: run_time_statistics.h:32
encrypto::motion::GetGitBranch
const char * GetGitBranch()
encrypto::motion::PrintMotionInfo
std::string PrintMotionInfo()
Definition: analysis.cpp:168
encrypto::motion::PrintStatistics
std::string PrintStatistics(const std::string &experiment_name, const AccumulatedRunTimeStatistics &execution_statistics, const AccumulatedCommunicationStatistics &communication_statistics)
Definition: analysis.cpp:176
encrypto::motion::AccumulatedCommunicationStatistics::ToJson
boost::json::object ToJson() const
Definition: analysis.cpp:156
encrypto::motion::AccumulatedCommunicationStatistics::PrintHumanReadable
std::string PrintHumanReadable() const
Definition: analysis.cpp:140
encrypto::motion::GetPid
std::size_t GetPid()
Definition: runtime_info.cpp:63
encrypto::motion::RunTimeStatistics::StatisticsId::kSbPresetup
@ kSbPresetup
runtime_info.h
encrypto::motion::RunTimeStatistics::StatisticsId::kGatesSetup
@ kGatesSetup
encrypto::motion::RunTimeStatistics::StatisticsId
StatisticsId
Definition: run_time_statistics.h:37
encrypto::motion::communication
Definition: backend.h:37
d
static const fe d
Definition: mycurve25519_tables.h:30
encrypto::motion::communication::TransportStatistics
Definition: transport.h:32
encrypto::motion::RunTimeStatistics::data
std::array< TimePointPair, static_cast< std::size_t >StatisticsId::kMax)+1 > data
Definition: run_time_statistics.h:71
run_time_statistics.h
encrypto::motion::AccumulatedRunTimeStatistics::Duration
ClockType::duration Duration
Definition: analysis.h:46
encrypto::motion::AccumulatedRunTimeStatistics::AccumulatorType
boost::accumulators::accumulator_set< double, boost::accumulators::stats< boost::accumulators::tag::mean, boost::accumulators::tag::median, boost::accumulators::tag::lazy_variance > > AccumulatorType
Definition: analysis.h:51
encrypto::motion::communication::TransportStatistics::number_of_bytes_sent
std::size_t number_of_bytes_sent
Definition: transport.h:35
encrypto::motion::AccumulatedCommunicationStatistics
Definition: analysis.h:65
encrypto::motion::detail::sqrt
T sqrt(size_t k, T a)
Definition: sb_impl.h:43
encrypto::motion::AccumulatedRunTimeStatistics::Add
void Add(const RunTimeStatistics &statistics)
Definition: analysis.cpp:43
encrypto::motion::RunTimeStatistics::StatisticsId::kSpSetup
@ kSpSetup