Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions BenchmarkNetworkFactories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "BenchmarkNetworkFactories.h"

#include <Swiften/Crypto/PlatformCryptoProvider.h>
#include <Swiften/IDN/IDNConverter.h>
#include <Swiften/IDN/PlatformIDNConverter.h>
#include <Swiften/Network/BoostConnectionFactory.h>
#include <Swiften/Network/BoostConnectionServerFactory.h>
Expand Down Expand Up @@ -76,8 +77,8 @@ Swift::NetworkEnvironment* BenchmarkNetworkFactories::getNetworkEnvironment() co
}

Swift::IDNConverter* BenchmarkNetworkFactories::getIDNConverter() const {
static Swift::IDNConverter* idn = Swift::PlatformIDNConverter::create();
return idn;
static auto idn = Swift::PlatformIDNConverter::create();
return idn.get();
}

Swift::CryptoProvider* BenchmarkNetworkFactories::getCryptoProvider() const {
Expand Down
2 changes: 1 addition & 1 deletion BenchmarkNetworkFactories.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once
#define private public // FIXME
#include <Swiften/EventLoop/BoostASIOEventLoop.h>
#define private private
#undef private
#include <Swiften/Network/NetworkFactories.h>
#include <Swiften/TLS/PlatformTLSFactories.h>

Expand Down
21 changes: 18 additions & 3 deletions LatencyWorkloadBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "IdleSession.h"

LatencyWorkloadBenchmark::LatencyWorkloadBenchmark(std::vector<Swift::NetworkFactories*> networkFactories, AccountDataProvider* accountProvider, Options& opt) : networkFactories(networkFactories), accountProvider(accountProvider), opt(opt), sessionsReadyToBenchmark(0) {
std::cout << "Creating sessions...";
constexpr int dotFrequency = 500;
std::cout << "Creating sessions";
std::cout.flush();

// create active sessions
for (int i = 0; i < opt.noOfActiveSessions / 2; ++i) {
Expand All @@ -25,6 +27,10 @@ LatencyWorkloadBenchmark::LatencyWorkloadBenchmark(std::vector<Swift::NetworkFac
activePair->onBenchmarkEnd.connect(boost::bind(&LatencyWorkloadBenchmark::handleBenchmarkEnd, this));
activeSessionPairs.push_back(activePair);
sessionsToActivate.push_back(activePair);
if (i % dotFrequency == 0) {
std::cout << ".";
std::cout.flush();
}
}

// create idle sessions
Expand All @@ -34,17 +40,26 @@ LatencyWorkloadBenchmark::LatencyWorkloadBenchmark(std::vector<Swift::NetworkFac
idleSession->onDoneBenchmarking.connect(boost::bind(&LatencyWorkloadBenchmark::handleBenchmarkSessionDone, this, idleSession));
idleSessions.push_back(idleSession);
sessionsToActivate.push_back(idleSession);
if (i % dotFrequency == 0) {
std::cout << ".";
std::cout.flush();
}
}

std::cout << "done." << std::endl;
std::cout << "Preparing sessions...";
std::cout << " done." << std::endl;
std::cout << "Preparing sessions";
std::cout.flush();

nextActivateSession = sessionsToActivate.begin();
for (size_t n = 0; n < opt.parallelLogins && n < sessionsToActivate.size(); ++n) {
(*nextActivateSession)->start();
++nextActivateSession;
if (n % dotFrequency == 0) {
std::cout << ".";
std::cout.flush();
}
}
std::cout << " done." << std::endl;
}

LatencyWorkloadBenchmark::~LatencyWorkloadBenchmark() {
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// #include <Swiften/EventLoop/SimpleEventLoop.h>
#define private public // FIXME
#include <Swiften/EventLoop/BoostASIOEventLoop.h>
#define private private
#undef private
#include <Swiften/JID/JID.h>
#include <Swiften/Network/BoostNetworkFactories.h>

Expand Down Expand Up @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) {
std::vector<BoostASIOEventLoop*> eventLoops;
std::vector<NetworkFactories*> networkFactories;

for (int n = 0; n < jobs; ++n) {
for (size_t n = 0; n < jobs; ++n) {
BoostASIOEventLoop* eventLoop = new BoostASIOEventLoop(std::make_shared<boost::asio::io_service>());
NetworkFactories* factory;
//if (jobs > 1) {
Expand Down