@@ -87,6 +87,97 @@ BENCHMARK_COUNTERS(ProductShareGenerator, counters) {
8787 benchmark.runBenchmark (counters);
8888}
8989
90+ class BaseTupleGeneratorBenchmark : public util ::NetworkedBenchmark {
91+ public:
92+ void setup () override {
93+ auto [agentFactory0, agentFactory1] = util::getSocketAgentFactories ();
94+ agentFactory0_ = std::move (agentFactory0);
95+ agentFactory1_ = std::move (agentFactory1);
96+
97+ senderFactory_ = getTupleGeneratorFactory (0 , *agentFactory0_);
98+ receiverFactory_ = getTupleGeneratorFactory (1 , *agentFactory1_);
99+ }
100+
101+ void runSender () override {
102+ sender_ = senderFactory_->create ();
103+ sender_->getBooleanTuple (size_);
104+ }
105+
106+ void runReceiver () override {
107+ receiver_ = receiverFactory_->create ();
108+ receiver_->getBooleanTuple (size_);
109+ }
110+
111+ std::pair<uint64_t , uint64_t > getTrafficStatistics () override {
112+ return sender_->getTrafficStatistics ();
113+ }
114+
115+ protected:
116+ virtual std::unique_ptr<ITupleGeneratorFactory> getTupleGeneratorFactory (
117+ int myId,
118+ communication::IPartyCommunicationAgentFactory& agentFactory) = 0;
119+
120+ size_t bufferSize_ = 1600000 ;
121+
122+ private:
123+ size_t size_ = 1000000 ;
124+
125+ std::unique_ptr<communication::IPartyCommunicationAgentFactory>
126+ agentFactory0_;
127+ std::unique_ptr<communication::IPartyCommunicationAgentFactory>
128+ agentFactory1_;
129+
130+ std::unique_ptr<ITupleGeneratorFactory> senderFactory_;
131+ std::unique_ptr<ITupleGeneratorFactory> receiverFactory_;
132+
133+ std::unique_ptr<ITupleGenerator> sender_;
134+ std::unique_ptr<ITupleGenerator> receiver_;
135+ };
136+
137+ class TupleGeneratorBenchmark final : public BaseTupleGeneratorBenchmark {
138+ protected:
139+ std::unique_ptr<ITupleGeneratorFactory> getTupleGeneratorFactory (
140+ int myId,
141+ communication::IPartyCommunicationAgentFactory& agentFactory) override {
142+ auto otFactory = std::make_unique<
143+ oblivious_transfer::RcotBasedBidirectionObliviousTransferFactory<bool >>(
144+ myId, agentFactory, oblivious_transfer::createFerretRcotFactory ());
145+ auto productShareGeneratorFactory =
146+ std::make_unique<ProductShareGeneratorFactory<bool >>(
147+ std::make_unique<util::AesPrgFactory>(bufferSize_),
148+ std::move (otFactory));
149+ return std::make_unique<TupleGeneratorFactory>(
150+ std::move (productShareGeneratorFactory),
151+ std::make_unique<util::AesPrgFactory>(),
152+ bufferSize_,
153+ myId,
154+ 2 );
155+ }
156+ };
157+
158+ BENCHMARK_COUNTERS (TupleGenerator, counters) {
159+ TupleGeneratorBenchmark benchmark;
160+ benchmark.runBenchmark (counters);
161+ }
162+
163+ class TwoPartyTupleGeneratorBenchmark final
164+ : public BaseTupleGeneratorBenchmark {
165+ protected:
166+ std::unique_ptr<ITupleGeneratorFactory> getTupleGeneratorFactory (
167+ int myId,
168+ communication::IPartyCommunicationAgentFactory& agentFactory) override {
169+ return std::make_unique<TwoPartyTupleGeneratorFactory>(
170+ oblivious_transfer::createFerretRcotFactory (),
171+ agentFactory,
172+ myId,
173+ bufferSize_);
174+ }
175+ };
176+
177+ BENCHMARK_COUNTERS (TwoPartyTupleGenerator, counters) {
178+ TwoPartyTupleGeneratorBenchmark benchmark;
179+ benchmark.runBenchmark (counters);
180+ }
90181} // namespace fbpcf::engine::tuple_generator
91182
92183int main (int argc, char * argv[]) {
0 commit comments