Skip to content

Commit

Permalink
Add more logging in test/benchmark apps (#250)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #250

As title.
This diff is a subset of D37323715 (9fd60f8)

Reviewed By: adshastri

Differential Revision: D37537259

fbshipit-source-id: 5b11b057a3318644beb757f05eac477964859bb3
  • Loading branch information
RuiyuZhu authored and facebook-github-bot committed Jun 29, 2022
1 parent d18f8ed commit 52fde4e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion example/billionaire_problem/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#include <folly/json.h>

#include <gflags/gflags.h>
#include "fbpcf/scheduler/SchedulerHelper.h"
#include "folly/init/Init.h"
Expand Down Expand Up @@ -34,7 +36,7 @@ int main(int argc, char* argv[]) {
{1, {FLAGS_server_ip, FLAGS_port}}});
auto factory = std::make_unique<
fbpcf::engine::communication::SocketPartyCommunicationAgentFactory>(
FLAGS_party, partyInfos);
FLAGS_party, partyInfos, "billionaire_problem_traffic");

auto game = std::make_unique<
fbpcf::billionaire_problem::BillionaireProblemGame<0, true>>(
Expand Down Expand Up @@ -79,4 +81,7 @@ int main(int argc, char* argv[]) {
XLOG(FATAL, "Failed to execute the game!");
}
XLOG(INFO, "Game executed successfully!");
XLOG(
INFO,
folly::toPrettyJson(factory->getMetricsCollector()->collectMetrics()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace fbpcf::engine::communication {
*/
class IPartyCommunicationAgentFactory {
public:
IPartyCommunicationAgentFactory(std::string name = "unnamed_traffic")
explicit IPartyCommunicationAgentFactory(std::string name)
: metricCollector_(std::make_shared<fbpcf::util::MetricCollector>(name)) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class InMemoryPartyCommunicationAgentFactory final
InMemoryPartyCommunicationAgentFactory(
int myId,
std::map<int, std::shared_ptr<HostInfo>>&& sharedHosts)
: myId_(myId), sharedHosts_(sharedHosts) {
: IPartyCommunicationAgentFactory("in_memory_traffic"),
myId_(myId),
sharedHosts_(sharedHosts) {
for (auto& item : sharedHosts_) {
createdAgentCount_.emplace(item.first, 0);
}
Expand Down
4 changes: 3 additions & 1 deletion fbpcf/engine/util/test/benchmarks/BenchmarkHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class BenchmarkSocketAgentFactory final
BenchmarkSocketAgentFactory(
int myId,
std::shared_ptr<AgentsByParty> agentsByParty)
: myId_(myId), agentsByParty_(agentsByParty) {}
: communication::IPartyCommunicationAgentFactory("benchmark_traffic"),
myId_(myId),
agentsByParty_(agentsByParty) {}

// The socket agents are stored in a queue.
// If a party calls create() and the queue is empty, create a new pair of
Expand Down

0 comments on commit 52fde4e

Please sign in to comment.