Skip to content

Commit

Permalink
Refs eProsima#1519. Added option for hostname usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
richiprosima committed Mar 1, 2016
1 parent 6520e9a commit 25dfbef
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 126 deletions.
22 changes: 17 additions & 5 deletions test/performance/LatencyTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ LatencyTestPublisher::~LatencyTestPublisher()
}


bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid)
bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname)
{
n_samples = n_sam;
n_subscribers = n_sub;
Expand Down Expand Up @@ -113,7 +113,10 @@ bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pi
PubDataparam.topic.topicDataType = "LatencyType";
PubDataparam.topic.topicKind = NO_KEY;
std::ostringstream pt;
pt << "LatencyTest_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
pt << "LatencyTest_";
if(hostname)
pt << boost::asio::ip::host_name() << "_";
pt << pid << "_PUB2SUB";
PubDataparam.topic.topicName = pt.str();
PubDataparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
PubDataparam.topic.historyQos.depth = n_samples +100;
Expand All @@ -132,7 +135,10 @@ bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pi
SubDataparam.topic.topicDataType = "LatencyType";
SubDataparam.topic.topicKind = NO_KEY;
std::ostringstream st;
st << "LatencyTest_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
st << "LatencyTest_";
if(hostname)
st << boost::asio::ip::host_name() << "_";
st << pid << "_SUB2PUB";
SubDataparam.topic.topicName = st.str();
SubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
SubDataparam.topic.historyQos.depth = 1;
Expand All @@ -153,7 +159,10 @@ bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pi
PubCommandParam.topic.topicDataType = "TestCommandType";
PubCommandParam.topic.topicKind = NO_KEY;
std::ostringstream pct;
pct << "LatencyTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
pct << "LatencyTest_Command_";
if(hostname)
pct << boost::asio::ip::host_name() << "_";
pct << pid << "_PUB2SUB";
PubCommandParam.topic.topicName = pct.str();
PubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
PubCommandParam.topic.historyQos.depth = 100;
Expand All @@ -167,7 +176,10 @@ bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pi
SubCommandParam.topic.topicDataType = "TestCommandType";
SubCommandParam.topic.topicKind = NO_KEY;
std::ostringstream sct;
sct << "LatencyTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
sct << "LatencyTest_Command_";
if(hostname)
sct << boost::asio::ip::host_name() << "_";
sct << pid << "_SUB2PUB";
SubCommandParam.topic.topicName = sct.str();
SubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
SubCommandParam.topic.historyQos.depth = 100;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/LatencyTestPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class LatencyTestPublisher {
boost::interprocess::interprocess_semaphore m_data_sema;
int m_status;
unsigned int n_received;
bool init(int n_sub,int n_sam, bool reliable, uint32_t pid);
bool init(int n_sub,int n_sam, bool reliable, uint32_t pid, bool hostname);
void run();
void analizeTimes(uint32_t datasize);
bool test(uint32_t datasize);
Expand Down
22 changes: 17 additions & 5 deletions test/performance/LatencyTestSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ LatencyTestSubscriber::~LatencyTestSubscriber()
Domain::removeParticipant(mp_participant);
}

bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid)
bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid, bool hostname)
{
m_echo = echo;
n_samples = nsam;
Expand All @@ -81,7 +81,10 @@ bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid
PubDataparam.topic.topicDataType = "LatencyType";
PubDataparam.topic.topicKind = NO_KEY;
std::ostringstream pt;
pt << "LatencyTest_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
pt << "LatencyTest_";
if(hostname)
pt << boost::asio::ip::host_name() << "_";
pt << pid << "_SUB2PUB";
PubDataparam.topic.topicName = pt.str();
PubDataparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
PubDataparam.topic.historyQos.depth = n_samples +100;
Expand All @@ -103,7 +106,10 @@ bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid
SubDataparam.topic.topicDataType = "LatencyType";
SubDataparam.topic.topicKind = NO_KEY;
std::ostringstream st;
st << "LatencyTest_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
st << "LatencyTest_";
if(hostname)
st << boost::asio::ip::host_name() << "_";
st << pid << "_PUB2SUB";
SubDataparam.topic.topicName = st.str();
SubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
SubDataparam.topic.historyQos.depth = 50;//n_samples+100;
Expand All @@ -124,7 +130,10 @@ bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid
PubCommandParam.topic.topicDataType = "TestCommandType";
PubCommandParam.topic.topicKind = NO_KEY;
std::ostringstream pct;
pct << "LatencyTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
pct << "LatencyTest_Command_";
if(hostname)
pct << boost::asio::ip::host_name() << "_";
pct << pid << "_SUB2PUB";
PubCommandParam.topic.topicName = pct.str();
PubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
PubCommandParam.topic.historyQos.depth = 100;
Expand All @@ -138,7 +147,10 @@ bool LatencyTestSubscriber::init(bool echo,int nsam, bool reliable, uint32_t pid
SubCommandParam.topic.topicDataType = "TestCommandType";
SubCommandParam.topic.topicKind = NO_KEY;
std::ostringstream sct;
sct << "LatencyTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
sct << "LatencyTest_Command_";
if(hostname)
sct << boost::asio::ip::host_name() << "_";
sct << pid << "_PUB2SUB";
SubCommandParam.topic.topicName = sct.str();
SubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
SubCommandParam.topic.historyQos.depth = 100;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/LatencyTestSubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LatencyTestSubscriber {
int m_status;
int n_received;
int n_samples;
bool init(bool echo,int nsam, bool reliable, uint32_t pid);
bool init(bool echo,int nsam, bool reliable, uint32_t pid, bool hostname);
void run();
bool test(uint32_t datasize);
class DataPubListener : public PublisherListener
Expand Down
17 changes: 13 additions & 4 deletions test/performance/ThroughputPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ThroughputPublisher::CommandPubListener::onPublicationMatched(Publisher* /*
}
}

ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid): sema(0),
ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid, bool hostname): sema(0),
#pragma warning(disable:4355)
m_DataPubListener(*this),m_CommandSubListener(*this),m_CommandPubListener(*this),
ready(true)
Expand Down Expand Up @@ -115,7 +115,10 @@ ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid): sema(0),
Wparam.topic.topicDataType = "ThroughputType";
Wparam.topic.topicKind = NO_KEY;
std::ostringstream pt;
pt << "ThroughputTest_" << boost::asio::ip::host_name() << "_" << pid << "_UP";
pt << "ThroughputTest_";
if(hostname)
pt << boost::asio::ip::host_name() << "_";
pt << pid << "_UP";
Wparam.topic.topicName = pt.str();

if(reliable)
Expand Down Expand Up @@ -149,7 +152,10 @@ ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid): sema(0),
Rparam.topic.topicDataType = "ThroughputCommand";
Rparam.topic.topicKind = NO_KEY;
std::ostringstream sct;
sct << "ThroughputTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
sct << "ThroughputTest_Command_";
if(hostname)
sct << boost::asio::ip::host_name() << "_";
sct << pid << "_SUB2PUB";
Rparam.topic.topicName = sct.str();
Rparam.qos.m_reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
mp_commandsub = Domain::createSubscriber(mp_par,Rparam,(SubscriberListener*)&this->m_CommandSubListener);
Expand All @@ -161,7 +167,10 @@ ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid): sema(0),
Wparam2.topic.topicDataType = "ThroughputCommand";
Wparam2.topic.topicKind = NO_KEY;
std::ostringstream pct;
pct << "ThroughputTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
pct << "ThroughputTest_Command_";
if(hostname)
pct << boost::asio::ip::host_name() << "_";
pct << pid << "_PUB2SUB";
Wparam2.topic.topicName = pct.str();
Wparam2.qos.m_reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
mp_commandpub = Domain::createPublisher(mp_par,Wparam2,(PublisherListener*)&this->m_CommandPubListener);
Expand Down
2 changes: 1 addition & 1 deletion test/performance/ThroughputPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace std;
class ThroughputPublisher
{
public:
ThroughputPublisher(bool reliable, uint32_t pid);
ThroughputPublisher(bool reliable, uint32_t pid, bool hostname);
virtual ~ThroughputPublisher();
Participant* mp_par;
Publisher* mp_datapub;
Expand Down
18 changes: 13 additions & 5 deletions test/performance/ThroughputSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ void ThroughputSubscriber::CommandPubListener::onPublicationMatched(Publisher* /

ThroughputSubscriber::~ThroughputSubscriber(){Domain::stopAll();}

ThroughputSubscriber::ThroughputSubscriber(bool reliable, uint32_t pid):
sema(0),
ThroughputSubscriber::ThroughputSubscriber(bool reliable, uint32_t pid, bool hostname) : sema(0),
#pragma warning(disable:4355)
m_DataSubListener(*this),m_CommandSubListener(*this),m_CommandPubListener(*this),
ready(true),m_datasize(0),m_demand(0)
Expand Down Expand Up @@ -226,7 +225,10 @@ ThroughputSubscriber::ThroughputSubscriber(bool reliable, uint32_t pid):
Sparam.topic.topicDataType = "ThroughputType";
Sparam.topic.topicKind = NO_KEY;
std::ostringstream st;
st << "ThroughputTest_" << boost::asio::ip::host_name() << "_" << pid << "_UP";
st << "ThroughputTest_";
if(hostname)
st << boost::asio::ip::host_name() << "_";
st << pid << "_UP";
Sparam.topic.topicName = st.str();

if(reliable)
Expand Down Expand Up @@ -256,7 +258,10 @@ ThroughputSubscriber::ThroughputSubscriber(bool reliable, uint32_t pid):
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.topicName = "ThroughputCommandP2S";
std::ostringstream sct;
sct << "ThroughputTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_PUB2SUB";
sct << "ThroughputTest_Command_";
if(hostname)
sct << boost::asio::ip::host_name() << "_";
sct << pid << "_PUB2SUB";
Rparam.topic.topicName = sct.str();
Rparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
Rparam.topic.historyQos.depth = 20;
Expand All @@ -273,7 +278,10 @@ ThroughputSubscriber::ThroughputSubscriber(bool reliable, uint32_t pid):
Wparam.topic.topicDataType = "ThroughputCommand";
Wparam.topic.topicKind = NO_KEY;
std::ostringstream pct;
pct << "ThroughputTest_Command_" << boost::asio::ip::host_name() << "_" << pid << "_SUB2PUB";
pct << "ThroughputTest_Command_";
if(hostname)
pct << boost::asio::ip::host_name() << "_";
pct << pid << "_SUB2PUB";
Wparam.topic.topicName = pct.str();
Wparam.qos.m_reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
mp_commandpubli = Domain::createPublisher(mp_par,Wparam,(PublisherListener*)&this->m_CommandPubListener);
Expand Down
2 changes: 1 addition & 1 deletion test/performance/ThroughputSubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace std;
class ThroughputSubscriber
{
public:
ThroughputSubscriber(bool reliable, uint32_t pid);
ThroughputSubscriber(bool reliable, uint32_t pid, bool hostname);
virtual ~ThroughputSubscriber();
Participant* mp_par;
Subscriber* mp_datasub;
Expand Down
4 changes: 2 additions & 2 deletions test/performance/latency_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import shlex, subprocess, time, os, socket, sys

command = os.environ.get("LATENCY_TEST_BIN")
subscriber_proc = subprocess.Popen([command, "subscriber", "--seed", str(os.getpid())])
publisher_proc = subprocess.Popen([command, "publisher", "--seed", str(os.getpid())])
subscriber_proc = subprocess.Popen([command, "subscriber", "--seed", str(os.getpid()), "--hostname"])
publisher_proc = subprocess.Popen([command, "publisher", "--seed", str(os.getpid()), "--hostname"])

subscriber_proc.communicate()
publisher_proc.communicate()
Expand Down
Loading

0 comments on commit 25dfbef

Please sign in to comment.