Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenRubio committed Mar 1, 2016
1 parent 25dfbef commit 70d8b27
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 97 deletions.
Binary file added doc/pdf/Fast RTPS - Latency Test.odt
Binary file not shown.
Binary file added doc/pdf/Fast RTPS - Throughput Test.odt
Binary file not shown.
123 changes: 117 additions & 6 deletions test/performance/LatencyTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ LatencyTestPublisher::~LatencyTestPublisher()
}


bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname)
bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname, bool export_csv)
{
n_samples = n_sam;
n_subscribers = n_sub;
n_export_csv = export_csv;

//////////////////////////////
/*
Expand All @@ -74,11 +75,48 @@ bool LatencyTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pi
strftime(date_buffer, 9, "%Y%m%d", now);
strftime(time_buffer, 7, "%H%M%S", now);
*/
output_file_name << "perf_LatencyTest.csv";
for (std::vector<uint32_t>::iterator it = data_size_pub.begin(); it != data_size_pub.end(); ++it) {
output_file << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"";
if (it != data_size_pub.end() - 1)
output_file << ",";

switch (*it + 4) {
case 16:
output_file_16 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 32:
output_file_32 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 64:
output_file_64 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 128:
output_file_128 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 256:
output_file_256 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 512:
output_file_512 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 1024:
output_file_1024 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 2048:
output_file_2048 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 4096:
output_file_4096 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 8192:
output_file_8192 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
case 16384:
output_file_16384 << "\"" << n_samples << " samples of " << *it + 4 << " bytes (us)\"" << std::endl;
break;
default:
break;
}
}
output_file << std::endl;
//////////////////////////////
Expand Down Expand Up @@ -329,10 +367,45 @@ void LatencyTestPublisher::run()
cout << "REMOVING SUBSCRIBER"<<endl;
Domain::removeSubscriber(mp_commandsub);

std::ofstream outFile;
outFile.open(output_file_name.str());
outFile << output_file.str();
outFile.close();
if (n_export_csv) {
std::ofstream outFile;
outFile.open("perf_LatencyTest.csv");
outFile << output_file.str();
outFile.close();
outFile.open("perf_LatencyTest_16.csv");
outFile << output_file_16.str();
outFile.close();
outFile.open("perf_LatencyTest_32.csv");
outFile << output_file_32.str();
outFile.close();
outFile.open("perf_LatencyTest_64.csv");
outFile << output_file_64.str();
outFile.close();
outFile.open("perf_LatencyTest_128.csv");
outFile << output_file_128.str();
outFile.close();
outFile.open("perf_LatencyTest_256.csv");
outFile << output_file_256.str();
outFile.close();
outFile.open("perf_LatencyTest_512.csv");
outFile << output_file_512.str();
outFile.close();
outFile.open("perf_LatencyTest_1024.csv");
outFile << output_file_1024.str();
outFile.close();
outFile.open("perf_LatencyTest_2048.csv");
outFile << output_file_2048.str();
outFile.close();
outFile.open("perf_LatencyTest_4096.csv");
outFile << output_file_4096.str();
outFile.close();
outFile.open("perf_LatencyTest_8192.csv");
outFile << output_file_8192.str();
outFile.close();
outFile.open("perf_LatencyTest_16384.csv");
outFile << output_file_16384.str();
outFile.close();
}
}

bool LatencyTestPublisher::test(uint32_t datasize)
Expand Down Expand Up @@ -466,6 +539,44 @@ void LatencyTestPublisher::printStat(TimeStats& TS)
{
output_file << "\"" << TS.mean << "\"";

switch (TS.nbytes) {
case 16:
output_file_16 << "\"" << TS.mean << "\"" << std::endl;
break;
case 32:
output_file_32 << "\"" << TS.mean << "\"" << std::endl;
break;
case 64:
output_file_64 << "\"" << TS.mean << "\"" << std::endl;
break;
case 128:
output_file_128 << "\"" << TS.mean << "\"" << std::endl;
break;
case 256:
output_file_256 << "\"" << TS.mean << "\"" << std::endl;
break;
case 512:
output_file_512 << "\"" << TS.mean << "\"" << std::endl;
break;
case 1024:
output_file_1024 << "\"" << TS.mean << "\"" << std::endl;
break;
case 2048:
output_file_2048 << "\"" << TS.mean << "\"" << std::endl;
break;
case 4096:
output_file_4096 << "\"" << TS.mean << "\"" << std::endl;
break;
case 8192:
output_file_8192 << "\"" << TS.mean << "\"" << std::endl;
break;
case 16384:
output_file_16384 << "\"" << TS.mean << "\"" << std::endl;
break;
default:
break;
}

printf("%8lu,%8u,%8.2f,%8.2f,%8.2f,%8.2f,%8.2f,%8.2f,%8.2f,%8.2f \n",
TS.nbytes, TS.received, TS.stdev, TS.mean,
TS.m_min.count(),
Expand Down
15 changes: 13 additions & 2 deletions test/performance/LatencyTestPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ 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 hostname);
bool n_export_csv;
bool init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname, bool export_csv);
void run();
void analizeTimes(uint32_t datasize);
bool test(uint32_t datasize);
Expand Down Expand Up @@ -102,8 +103,18 @@ class LatencyTestPublisher {
LatencyDataType latency_t;
TestCommandDataType command_t;

std::stringstream output_file_name;
std::stringstream output_file;
std::stringstream output_file_16;
std::stringstream output_file_32;
std::stringstream output_file_64;
std::stringstream output_file_128;
std::stringstream output_file_256;
std::stringstream output_file_512;
std::stringstream output_file_1024;
std::stringstream output_file_2048;
std::stringstream output_file_4096;
std::stringstream output_file_8192;
std::stringstream output_file_16384;
};


Expand Down
2 changes: 1 addition & 1 deletion 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 hostname)
bool LatencyTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid, bool hostname)
{
m_echo = echo;
n_samples = nsam;
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 hostname);
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
10 changes: 5 additions & 5 deletions test/performance/ThroughputPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ void ThroughputPublisher::CommandPubListener::onPublicationMatched(Publisher* /*
}
}

ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid, bool hostname): sema(0),
ThroughputPublisher::ThroughputPublisher(bool reliable, uint32_t pid, bool hostname, bool export_csv): sema(0),
#pragma warning(disable:4355)
m_DataPubListener(*this),m_CommandSubListener(*this),m_CommandPubListener(*this),
m_DataPubListener(*this), m_CommandSubListener(*this), m_CommandPubListener(*this), m_export_csv(export_csv),
ready(true)
{
ParticipantAttributes PParam;
Expand Down Expand Up @@ -332,13 +332,13 @@ bool ThroughputPublisher::test(uint32_t test_time, uint32_t recovery_time_ms, ui

bool ThroughputPublisher::loadDemandsPayload()
{
std::ifstream fi(file_name);
std::ifstream fi(m_file_name);

cout << "Reading File: " << file_name << endl;
cout << "Reading File: " << m_file_name << endl;
std::string DELIM = ";";
if(!fi.is_open())
{
std::cout << "Could not open file: " << file_name << " , closing." << std::endl;
std::cout << "Could not open file: " << m_file_name << " , closing." << std::endl;
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions 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, bool hostname);
ThroughputPublisher(bool reliable, uint32_t pid, bool hostname, bool export_csv);
virtual ~ThroughputPublisher();
Participant* mp_par;
Publisher* mp_datapub;
Expand Down Expand Up @@ -94,7 +94,8 @@ class ThroughputPublisher
bool loadDemandsPayload();
std::map<uint32_t,std::vector<uint32_t>> m_demand_payload;

std::string file_name;
std::string m_file_name;
bool m_export_csv;

std::stringstream output_file_name;
std::stringstream output_file;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/latency_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

0 comments on commit 70d8b27

Please sign in to comment.