diff --git a/perftest_qos_profiles.xml b/perftest_qos_profiles.xml index b2b2eff0..3918dedb 100644 --- a/perftest_qos_profiles.xml +++ b/perftest_qos_profiles.xml @@ -1090,5 +1090,23 @@ _KeepDurationUsec variable name corresponds to the command-line option -keepDura + + + + + + + + BEST_EFFORT_RELIABILITY_QOS + + + + 10 + 1 + 1 + + + + diff --git a/srcCpp/RTIDDSImpl.cxx b/srcCpp/RTIDDSImpl.cxx index 8287c8f3..b9f000dc 100644 --- a/srcCpp/RTIDDSImpl.cxx +++ b/srcCpp/RTIDDSImpl.cxx @@ -4274,6 +4274,317 @@ bool RTIDDSImpl_FlatData::get_serialized_overhead_size( #endif +void PerftestDDSPrinter::initialize(ParameterManager *_PM) +{ + PerftestPrinter::initialize(_PM); + this->_PM = _PM; + topicName = std::string("PerftestInfo"); +} + +void PerftestDDSPrinter::initialize_dds_entities() +{ + DDS_ReturnCode_t retcode; + + DDS_DomainParticipantFactoryQos factory_qos; + DDS_DomainParticipantQos dpQos; + DDS_PublisherQos publisherQos; + DDS_DataWriterQos dwQos; + + #ifndef RTI_MICRO + retcode = DDSTheParticipantFactory->get_qos(factory_qos); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "DDSTheParticipantFactory->get_qos(factory_qos)\n"); + return; + } + + if (!_PM->get("noXmlQos")) { + factory_qos.profile.url_profile.ensure_length(1, 1); + factory_qos.profile.url_profile[0] = + DDS_String_dup(_PM->get("qosFile").c_str()); + } else { + factory_qos.profile.string_profile.from_array( + PERFTEST_QOS_STRING, + PERFTEST_QOS_STRING_SIZE); + } + + retcode = DDSTheParticipantFactory->set_qos(factory_qos); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "DDSTheParticipantFactory->set_qos(factory_qos) failed\n"); + return; + } + + retcode = DDSTheParticipantFactory->reload_profiles(); + if ( retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "Problem opening QOS profiles file %s.\n", + _PM->get("qosFile").c_str()); + return; + } + + retcode = DDSTheParticipantFactory->get_participant_qos_from_profile( + dpQos, + _PM->get("qosLibrary").c_str(), + "LoggingQos"); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "Problem setting QoS Library \"%s::LoggingQos\" " + "for participant_qos.\n", + _PM->get("qosLibrary").c_str()); + return; + } + + retcode = DDSTheParticipantFactory->get_publisher_qos_from_profile( + publisherQos, + _PM->get("qosLibrary").c_str(), + "LoggingQos"); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "Problem setting QoS Library for publisherQos.\n"); + } + + retcode = DDSTheParticipantFactory->get_datawriter_qos_from_profile( + dwQos, + _PM->get("qosLibrary").c_str(), + "LoggingQos"); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "Problem setting QoS Library for dwQos.\n"); + } + #endif + + //TODO: Decide if we want to use the same domain or + 1 or what. + participant = DDSTheParticipantFactory->create_participant( + (DDS_DomainId_t) (_PM->get("domain") + 1), + dpQos, + NULL, + DDS_STATUS_MASK_NONE); + if (participant == NULL) { + fprintf(stderr, "PerftestDDSPrinter Problem creating participant.\n"); + finalize(); + } + + publisher = participant->create_publisher( + publisherQos, + NULL, + DDS_STATUS_MASK_NONE); + if (publisher == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "PerftestDDSPrinter create_publisher error\n"); + finalize(); + } + + retcode = PerftestInfo::TypeSupport::register_type( + participant, + PerftestInfo::TypeSupport::get_type_name()); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "PerftestDDSPrinter register_type error %d\n", + retcode); + finalize(); + } + + topic = participant->create_topic( + topicName.c_str(), + PerftestInfo::TypeSupport::get_type_name(), + DDS_TOPIC_QOS_DEFAULT, + NULL, + DDS_STATUS_MASK_NONE); + if (topic == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "PerftestDDSPrinter create_topic error\n"); + finalize(); + } + + DDSDataWriter *writer = publisher->create_datawriter( + topic, dwQos, NULL, + DDS_STATUS_MASK_NONE); + if (writer == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "PerftestDDSPrinter create_datawriter error\n"); + finalize(); + } + + infoDataWriter = PerftestInfo::DataWriter::narrow(writer); + if (infoDataWriter == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "DataWriter narrow error\n"); + finalize(); + } + + perftestInfo = PerftestInfo::TypeSupport::create_data(); + if (perftestInfo == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "testTypeSupport::create_data error\n"); + finalize(); + } + + perftestInfo->latencyInfo = PerftestLatencyInfo::TypeSupport::create_data(); + if (perftestInfo->latencyInfo == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "testTypeSupport::create_data error\n"); + finalize(); + } + perftestInfo->throughputInfo = PerftestThroughputInfo::TypeSupport::create_data(); + if (perftestInfo->throughputInfo == NULL) { + fprintf(stderr, + "PerftestDDSPrinter::initialize: " + "testTypeSupport::create_data error\n"); + finalize(); + } + + if (_PM->get("pub")) { + perftestInfo->latencyInfo->pubId = _PM->get("pidMultiPubTest"); + } else { + perftestInfo->throughputInfo->subId = _PM->get("sidMultiSubTest"); + } + + fprintf(stderr, + "[Info] Publishing latency/throughput information via DDS\n"); +} + +void PerftestDDSPrinter::finalize() +{ + DDS_ReturnCode_t retcode; + + deleteDataSample(); + retcode = PerftestInfo::TypeSupport::delete_data(perftestInfo); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, "PerftestInfo::TypeSupport::delete_data error %d\n", retcode); + } + + if (participant != NULL) { + retcode = participant->delete_contained_entities(); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, "delete_contained_entities error %d\n", retcode); + } + retcode = DDSTheParticipantFactory->delete_participant(participant); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, "delete_participant error %d\n", retcode); + } + } +} + +void PerftestDDSPrinter::print_latency_interval(LatencyInfo latencyInfo) +{ + this->dataWrapperLatency(latencyInfo); + DDS_ReturnCode_t retcode = infoDataWriter->write(*perftestInfo, DDS_HANDLE_NIL); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::print_latency_interval" + "write error %d\n", + retcode); + } +} + +void PerftestDDSPrinter::print_throughput_interval(ThroughputInfo throughputInfo) +{ + DDS_ReturnCode_t retcode; + this->dataWrapperThroughput(throughputInfo); + retcode = infoDataWriter->write(*perftestInfo, DDS_HANDLE_NIL); + if (retcode != DDS_RETCODE_OK) { + fprintf(stderr, + "PerftestDDSPrinter::print_latency_interval" + "write error %d\n", + retcode); + } +} + +void PerftestDDSPrinter::deleteDataSample() +{ + perftestInfo->outputCpu = NULL; + perftestInfo->latencyInfo->latency = NULL; + perftestInfo->latencyInfo->average = NULL; + perftestInfo->latencyInfo->std = NULL; + perftestInfo->latencyInfo->minimum = NULL; + perftestInfo->latencyInfo->maximum = NULL; + perftestInfo->latencyInfo->percentile50 = NULL; + perftestInfo->latencyInfo->percentile90 = NULL; + perftestInfo->latencyInfo->percentile99 = NULL; + perftestInfo->latencyInfo->percentile9999 = NULL; + perftestInfo->latencyInfo->percentile999999 = NULL; + perftestInfo->latencyInfo->serializeTime = NULL; + perftestInfo->latencyInfo->deserializeTime = NULL; + perftestInfo->throughputInfo->packets = NULL; + perftestInfo->throughputInfo->packetsAverage = NULL; + perftestInfo->throughputInfo->mbps = NULL; + perftestInfo->throughputInfo->mbpsAverage = NULL; + perftestInfo->throughputInfo->lostPackets = NULL; + perftestInfo->throughputInfo->lostPacketsPercent = NULL; + perftestInfo->throughputInfo->packetsPerSecond = NULL; +} + +void PerftestDDSPrinter::dataWrapperLatency(LatencyInfo latencyInfo) +{ + if (this->_dataLength != perftestInfo->dataLength) { + perftestInfo->dataLength = _dataLength; + } + + if (this->_showCPU) { + perftestInfo->outputCpu = &latencyInfo.outputCpu; + } + perftestInfo->latencyInfo->latency = &latencyInfo.latency; + perftestInfo->latencyInfo->average = &latencyInfo.average; + perftestInfo->latencyInfo->std = &latencyInfo.std; + perftestInfo->latencyInfo->minimum = &latencyInfo.minimum; + perftestInfo->latencyInfo->maximum = &latencyInfo.maximum; + // summary part + if (!latencyInfo.interval) { + perftestInfo->latencyInfo->percentile50 = &latencyInfo.percentile50; + perftestInfo->latencyInfo->percentile90 = &latencyInfo.percentile90; + perftestInfo->latencyInfo->percentile99 = &latencyInfo.percentile99; + perftestInfo->latencyInfo->percentile9999 = &latencyInfo.percentile9999; + perftestInfo->latencyInfo->percentile999999 = &latencyInfo.percentile999999; + if (_printSerialization) { + perftestInfo->latencyInfo->serializeTime = &latencyInfo.serializeTime; + perftestInfo->latencyInfo->deserializeTime = &latencyInfo.deserializeTime; + } + } else { + perftestInfo->latencyInfo->percentile50 = NULL; + perftestInfo->latencyInfo->percentile90 = NULL; + perftestInfo->latencyInfo->percentile99 = NULL; + perftestInfo->latencyInfo->percentile9999 = NULL; + perftestInfo->latencyInfo->percentile999999 = NULL; + perftestInfo->latencyInfo->serializeTime = NULL; + perftestInfo->latencyInfo->deserializeTime = NULL; + } +} + +void PerftestDDSPrinter::dataWrapperThroughput(ThroughputInfo throughputInfo) +{ + if (this->_dataLength != perftestInfo->dataLength) { + perftestInfo->dataLength = _dataLength; + } + if (this->_showCPU) { + perftestInfo->outputCpu = &throughputInfo.outputCpu; + } + perftestInfo->throughputInfo->packets = &throughputInfo.packets; + perftestInfo->throughputInfo->packetsAverage = &throughputInfo.packetsAverage; + perftestInfo->throughputInfo->mbps = &throughputInfo.mbps; + perftestInfo->throughputInfo->mbpsAverage = &throughputInfo.mbpsAve; + perftestInfo->throughputInfo->lostPackets = &throughputInfo.lostPackets; + perftestInfo->throughputInfo->lostPacketsPercent = &throughputInfo.lostPacketsPercent; + if (throughputInfo.interval) { + perftestInfo->throughputInfo->packetsPerSecond = &throughputInfo.packetsPerSecond; + } else { + perftestInfo->throughputInfo->packetsPerSecond = NULL; + } +} + /* * This instantiation is to avoid a undefined reference of a templated static * function of obtain_dds_de/serialize_time_costs. diff --git a/srcCpp/RTIDDSImpl.h b/srcCpp/RTIDDSImpl.h index d1bcb0fc..de67ca90 100644 --- a/srcCpp/RTIDDSImpl.h +++ b/srcCpp/RTIDDSImpl.h @@ -14,6 +14,7 @@ #include "perftestSupport.h" #include "PerftestTransport.h" #include "Infrastructure_common.h" +#include "PerftestPrinter.h" #ifdef RTI_ZEROCOPY_AVAILABLE #include "perftest_ZeroCopySupport.h" @@ -243,4 +244,50 @@ class RTIDDSImpl_FlatData: public RTIDDSImpl { }; #endif // RTI_FLATDATA_AVAILABLE +class PerftestDDSPrinter: public PerftestPrinter { + + int domain; + std::string topicName; + + ParameterManager *_PM; + DDSDomainParticipant *participant; + DDSPublisher *publisher; + DDSTopic *topic; + PerftestInfoDataWriter *infoDataWriter; + PerftestInfo *perftestInfo; + + ~PerftestDDSPrinter() {}; + + void initialize(ParameterManager *_PM); + void initialize_dds_entities(); + void finalize(); + + void print_initial_output() + { + initialize_dds_entities(); + }; + void print_final_output() + { + finalize(); + }; + + void print_latency_header() {}; + void print_latency_interval(LatencyInfo latencyInfo); + void print_latency_summary(LatencyInfo latencyInfo) + { + print_latency_interval(latencyInfo); + }; + + void print_throughput_header() {}; + void print_throughput_interval(ThroughputInfo throughputInfo); + void print_throughput_summary(ThroughputInfo throughputInfo) + { + print_throughput_interval(throughputInfo); + }; + + void dataWrapperLatency(LatencyInfo latencyInfo); + void dataWrapperThroughput(ThroughputInfo throughputInfo); + void deleteDataSample(); +}; + #endif // __RTIDDSIMPL_H__ diff --git a/srcCpp/perftest_cpp.h b/srcCpp/perftest_cpp.h index 01af749a..27ef4761 100644 --- a/srcCpp/perftest_cpp.h +++ b/srcCpp/perftest_cpp.h @@ -52,7 +52,7 @@ class perftest_cpp // Private members ParameterManager _PM; - PerftestPrinter _printer; + PerftestPrinter *_printer; unsigned long long _SpinLoopCount; unsigned long _SleepNanosec; IMessaging *_MessagingImpl; diff --git a/srcCpp/perftest_publisher.cxx b/srcCpp/perftest_publisher.cxx index 4943ebc0..032451a2 100644 --- a/srcCpp/perftest_publisher.cxx +++ b/srcCpp/perftest_publisher.cxx @@ -153,8 +153,6 @@ int perftest_cpp::Run(int argc, char *argv[]) return -1; } - _printer.initialize(&_PM); - if (_PM.get("rawTransport")) { #ifndef RTI_MICRO _MessagingImpl = new RTIRawTransportImpl(); @@ -227,6 +225,18 @@ int perftest_cpp::Run(int argc, char *argv[]) return -1; } + std::string outputFormat = _PM.get("outputFormat"); + if (outputFormat == "csv") { + _printer = new PerftestCSVPrinter(); + } else if (outputFormat == "json") { + _printer = new PerftestJSONPrinter(); + } else if (outputFormat == "legacy") { + _printer = new PerftestLegacyPrinter(); + } else if (outputFormat == "dds") { + _printer = new PerftestDDSPrinter(); + } + _printer->initialize(&_PM); + PrintConfiguration(); if (_PM.get("pub")) { @@ -277,6 +287,10 @@ perftest_cpp::~perftest_cpp() delete _MessagingImpl; } + if (_printer != NULL) { + delete _printer; + } + fprintf(stderr, "Test ended.\n"); fflush(stderr); } @@ -296,6 +310,7 @@ perftest_cpp::perftest_cpp() _SpinLoopCount = 0; _SleepNanosec = 0; _MessagingImpl = NULL; + _printer = NULL; /* * We use rand to generate the key of a SHMEM segment when @@ -701,6 +716,7 @@ class ThroughputListener : public IMessagingCB bool printIntervals; bool cacheStats; bool showCpu; + ThroughputInfo _throughputInfo; public: @@ -715,7 +731,6 @@ class ThroughputListener : public IMessagingCB unsigned long long interval_bytes_received; unsigned long long interval_missing_packets; unsigned long long interval_time, begin_time; - float missing_packets_percent; unsigned int sample_count_peak; IMessagingWriter *_writer; @@ -731,7 +746,7 @@ class ThroughputListener : public IMessagingCB ThroughputListener( ParameterManager &PM, - PerftestPrinter &printer, + PerftestPrinter *printer, IMessagingWriter *writer, IMessagingReader *reader = NULL, bool UseCft = false, @@ -749,7 +764,6 @@ class ThroughputListener : public IMessagingCB interval_missing_packets = 0; sample_count_peak = 0; interval_time = 0; - missing_packets_percent = 0.0; begin_time = 0; _writer = writer; _reader = reader; @@ -763,7 +777,10 @@ class ThroughputListener : public IMessagingCB _num_publishers = numPublishers; _PM = &PM; - _printer = &printer; + _printer = printer; + + _throughputInfo.dataLength = _printer->_dataLength; + _throughputInfo.outputCpu = 0.0; printIntervals = !_PM->get("noPrintIntervals"); cacheStats = _PM->get("cacheStats"); @@ -850,8 +867,7 @@ class ThroughputListener : public IMessagingCB } begin_time = PerftestClock::getInstance().getTime(); - _printer->set_data_length(message.size - + perftest_cpp::OVERHEAD_BYTES); + _printer->_dataLength = message.size + perftest_cpp::OVERHEAD_BYTES; _printer->print_throughput_header(); } @@ -901,29 +917,22 @@ class ThroughputListener : public IMessagingCB interval_bytes_received = bytes_received; interval_missing_packets = missing_packets; interval_data_length = last_data_length; - missing_packets_percent = 0; - // Calculations of missing package percent - if (interval_packets_received + interval_missing_packets != 0) { - missing_packets_percent = (float) ((interval_missing_packets * 100.0) - / (float) (interval_packets_received - + interval_missing_packets)); - } - double outputCpu = 0.0; if (showCpu) { - outputCpu = cpu.get_cpu_average(); + _throughputInfo.outputCpu = cpu.get_cpu_average(); cpu = CpuMonitor(); cpu.initialize(); } - _printer->print_throughput_summary( - interval_data_length + perftest_cpp::OVERHEAD_BYTES, + + _throughputInfo.set_summary( interval_packets_received, interval_time, interval_bytes_received, - interval_missing_packets, - missing_packets_percent, - outputCpu); + interval_missing_packets); + + _printer->print_throughput_summary(_throughputInfo); + if (cacheStats) { printf("Samples Ping Reader Queue Peak: %4d\n", sample_count_peak); } @@ -998,6 +1007,7 @@ int perftest_cpp::Subscriber() IMessagingWriter *writer; IMessagingWriter *announcement_writer; struct PerftestThread *throughputThread = NULL; + ThroughputInfo _throughputInfo; // create latency pong writer writer = _MessagingImpl->CreateWriter(LATENCY_TOPIC_NAME); @@ -1117,7 +1127,7 @@ int perftest_cpp::Subscriber() fflush(stderr); // For Json format, print brackets at init - _printer.print_initial_output(); + _printer->print_initial_output(); // wait for data unsigned long long prev_time = 0, now = 0, delta = 0; @@ -1128,7 +1138,6 @@ int perftest_cpp::Subscriber() unsigned long long mps = 0, bps = 0; double mps_ave = 0.0, bps_ave = 0.0; unsigned long long msgsent, bytes, last_msgs, last_bytes; - float missing_packets_percent = 0; const bool cacheStats = _PM.get("cacheStats"); @@ -1186,30 +1195,18 @@ int perftest_cpp::Subscriber() bps_ave = bps_ave + (double)(bps - bps_ave) / (double)ave_count; mps_ave = mps_ave + (double)(mps - mps_ave) / (double)ave_count; - // Calculations of missing package percent - if (last_msgs + reader_listener->missing_packets == 0) { - missing_packets_percent = 0.0; - } else { - missing_packets_percent = (float) - ((reader_listener->missing_packets * 100.0) - / (float) (last_msgs + reader_listener->missing_packets)); - } - if (last_msgs > 0) { - double outputCpu = 0.0; if (showCpu) { - outputCpu = reader_listener->cpu.get_cpu_instant(); + _throughputInfo.outputCpu = reader_listener->cpu.get_cpu_instant(); } - _printer.print_throughput_interval( + _throughputInfo.set_interval( last_msgs, mps, mps_ave, bps, bps_ave, - reader_listener->missing_packets, - missing_packets_percent, - outputCpu); - fflush(stdout); + reader_listener->missing_packets); + _printer->print_throughput_interval(_throughputInfo); if (cacheStats) { printf("Samples Ping Reader Queue: %4d (Peak: %4d)", @@ -1225,7 +1222,7 @@ int perftest_cpp::Subscriber() } PerftestClock::milliSleep(2000); - _printer.print_final_output(); + _printer->print_final_output(); if (!finalize_read_thread(throughputThread, reader_listener)) { fprintf(stderr, "Error deleting throughputThread\n"); return -1; @@ -1330,6 +1327,7 @@ class LatencyListener : public IMessagingCB IMessagingWriter *_writer; ParameterManager *_PM; PerftestPrinter *_printer; + LatencyInfo _latencyInfo; int subID; bool printIntervals; bool showCpu; @@ -1344,7 +1342,7 @@ class LatencyListener : public IMessagingCB IMessagingReader *reader, IMessagingWriter *writer, ParameterManager &PM, - PerftestPrinter &printer) + PerftestPrinter *printer) { latency_sum = 0; latency_sum_square = 0; @@ -1385,7 +1383,10 @@ class LatencyListener : public IMessagingCB _reader = reader; _writer = writer; _PM = &PM; - _printer = &printer; + _printer = printer; + + _latencyInfo.dataLength = last_data_length; + _latencyInfo.outputCpu = 0.0; subID = _PM->get("sidMultiSubTest"); printIntervals = !_PM->get("noPrintIntervals"); @@ -1396,13 +1397,10 @@ class LatencyListener : public IMessagingCB unsigned short mask; double latency_ave; double latency_std; - #ifndef RTI_MICRO double serializeTime = -1; double deserializeTime = -1; - #endif int totalSampleSize = last_data_length + perftest_cpp::OVERHEAD_BYTES; - double outputCpu = 0.0; if (count == 0) { if (endTest) { @@ -1433,7 +1431,7 @@ class LatencyListener : public IMessagingCB latency_std = sqrt((double)latency_sum_square / (double)count - (latency_ave * latency_ave)); if (showCpu) { - outputCpu = cpu.get_cpu_average(); + _latencyInfo.outputCpu = cpu.get_cpu_average(); cpu = CpuMonitor(); cpu.initialize(); } @@ -1541,18 +1539,7 @@ class LatencyListener : public IMessagingCB } #endif - #ifdef RTI_MICRO - _printer->print_latency_summary( - latency_ave, - latency_std, - latency_min, - latency_max, - _latency_history, - count, - outputCpu); - #else - _printer->print_latency_summary( - totalSampleSize, + _latencyInfo.set_summary( latency_ave, latency_std, latency_min, @@ -1560,9 +1547,9 @@ class LatencyListener : public IMessagingCB _latency_history, count, serializeTime, - deserializeTime, - outputCpu); - #endif + deserializeTime); + + _printer->print_latency_summary(_latencyInfo); latency_sum = 0; latency_sum_square = 0; @@ -1589,7 +1576,6 @@ class LatencyListener : public IMessagingCB unsigned int usec; double latency_ave; double latency_std; - double outputCpu = 0.0; now = PerftestClock::getInstance().getTime(); @@ -1679,9 +1665,10 @@ class LatencyListener : public IMessagingCB if (last_data_length != message.size) { last_data_length = message.size; - _printer->set_data_length(last_data_length - + perftest_cpp::OVERHEAD_BYTES); + _printer->_dataLength = + last_data_length + perftest_cpp::OVERHEAD_BYTES; _printer->print_latency_header(); + } else { if (printIntervals) { @@ -1690,15 +1677,17 @@ class LatencyListener : public IMessagingCB (double)latency_sum_square / (double)count - (latency_ave * latency_ave)); if (showCpu) { - outputCpu = cpu.get_cpu_instant(); + _latencyInfo.outputCpu = cpu.get_cpu_instant(); } - _printer->print_latency_interval( - latency, - latency_ave, - latency_std, - latency_min, - latency_max, - outputCpu); + + _latencyInfo.set_interval( + latency, + latency_ave, + latency_std, + latency_min, + latency_max); + + _printer->print_latency_interval(_latencyInfo); } } @@ -1959,7 +1948,7 @@ int perftest_cpp::Publisher() fprintf(stderr,"Publishing data ...\n"); fflush(stderr); - _printer.print_initial_output(); + _printer->print_initial_output(); // Set data size, account for other bytes in message message.size = (int)_PM.get("dataLen") - OVERHEAD_BYTES; @@ -2315,7 +2304,7 @@ int perftest_cpp::Publisher() delete []message.data; } // For Json format, print last brackets - _printer.print_final_output(); + _printer->print_final_output(); if (_testCompleted) { // Delete timeout thread if (executionTimeoutThread != NULL) { diff --git a/srcCpp/qos_string.h b/srcCpp/qos_string.h index 99d58f93..6afda79a 100644 --- a/srcCpp/qos_string.h +++ b/srcCpp/qos_string.h @@ -1,6 +1,6 @@ #include #define PERFTEST_QOS_STRING_SIZE 46 -#define PERFTEST_QOS_STRING_TOTAL_SIZE 46411 +#define PERFTEST_QOS_STRING_TOTAL_SIZE 46893 const char * PERFTEST_QOS_STRING[PERFTEST_QOS_STRING_SIZE] = { "\n\n\n\n\n\n\n\n\n\n \n\n \n \n \n\n \n\n \n \n \n 4096\n\n \n 64\n \n 512\n \n\n \n\n \n\n \n \n\n \n \n dds.participant.property_validation_action\n 1\n \n\n ", " \n \n dds.transport.UDPv4.builtin.parent.message_size_max\n 65536\n \n \n dds.transport.UDPv4.builtin.send_socket_buffer_size\n 1048576\n \n \n dds.transport.UDPv4.builtin.recv_socket_buffer_size\n 2097152\n \n\n \n\n \n \n dds.transport.TCPv4.tcp1.library\n nddstransporttcp\n \n \n dds.transport.TCPv4.tcp1.create_function\n NDDS_Transport_TCPv4_create\n \n \n dds.transport.TCPv4.tcp1.disable_nagle\n 1\n \n \n dds.transport.TCPv4.tcp1.parent.message_size_max\n 65536\n \n\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.max_tokens\n 300\n \n ", -" \n dds.flow_controller.token_bucket.10Gbps.token_bucket.tokens_added_per_period\n 200\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.max_tokens\n 30\n \n \n dds.flow_controller.token_bucket.1G", -"bps.token_bucket.tokens_added_per_period\n 20\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n\n \n \n PerfTest Participant\n \n\n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n DURATION_ZERO_SEC\n 100000\n \n \n \n\n \n\n \n\n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n\n \n \n \n 256\n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n \n \n \n\n \n\n \n\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n \n \n \n DURATION_ZERO_SEC\n 1000000\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n\n \n LENGTH_UNLIMITED\n\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n \n\n \n \n false\n\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n false\n \n\n \n false\n \n\n \n\n \n\n \n \n\n \n \n KEEP_ALL_HISTORY_QOS\n", -" \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n\n \n \n 10000\n 128\n\n \n 10000\n \n\n \n \n 10000\n\n \n 65536\n \n\n \n ", -" \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC", -"\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n\n \n \n \n\n \n \n\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n LENGTH_UNLIMITED\n 100\n LENGTH_UNLIMITED\n \n \n \n \n \n 10\n 100\n 1000\n \n DURATION_ZERO_SEC\n 10000000\n \n \n DURATION_ZERO_SEC\n 1000000\n \n \n DURATION_ZERO_SEC\n 10000000\n \n LENGTH_UNLIMITED\n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n <", -"/max_nack_response_delay>\n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n \n \n\n \n false\n \n\n \n\n\n \n \n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n \n \n \n 100\n 100\n 100\n \n\n \n 100\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC", -"\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n \n\n \n \n \n\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE", -"_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n \n \n\n" }; +"ent>\n \n dds.transport.shmem.builtin.received_message_count_max\n 128\n \n \n dds.transport.shmem.builtin.receive_buffer_size\n 2097152\n \n -->\n\n \n \n dds.transport.TCPv4.tcp1.library\n nddstransporttcp\n \n \n dds.transport.TCPv4.tcp1.create_function\n NDDS_Transport_TCPv4_create\n \n \n dds.transport.TCPv4.tcp1.disable_nagle\n 1\n \n \n dds.transport.TCPv4.tcp1.parent.message_size_max\n 65536\n \n\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.max_tokens\n 300\n \n ", +" \n dds.flow_controller.token_bucket.10Gbps.token_bucket.tokens_added_per_period\n 200\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.max_tokens\n 30\n \n \n dds.flow_controller.token_bucket.1Gbps.t", +"oken_bucket.tokens_added_per_period\n 20\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n\n \n \n PerfTest Participant\n \n\n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n DURATION_ZERO_SEC\n 100000\n \n \n \n\n \n\n \n\n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n\n \n \n \n 256\n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n \n \n \n\n \n\n \n\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n \n \n \n DURATION_ZERO_SEC\n 1000000\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n\n \n LENGTH_UNLIMITED\n\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n \n\n \n \n false\n\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n false\n \n\n \n false\n \n\n \n\n \n\n \n \n\n \n \n KEEP_ALL_HISTORY_QOS\n ", +" \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n\n \n \n 10000\n 128\n\n \n 10000\n \n\n \n \n 10000", +"\n\n \n 65536\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n ", +" \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n\n \n \n \n\n \n \n\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n LENGTH_UNLIMITED\n 100\n LENGTH_UNLIMITED\n \n \n \n \n \n 10\n 100\n 1000\n \n DURATION_ZERO_SEC\n 10000000\n \n \n DURATION_ZERO_SEC\n 1000000\n \n \n DURATION_ZERO_SEC\n 10000000\n \n LENGTH_UNLIMITED\n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n \n \n\n \n false\n \n\n \n\n\n \n \n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n \n \n \n 100\n 100\n 100\n \n\n \n 100\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n ", +" \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n \n\n \n \n \n\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC", +"\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n \n\n \n\n \n\n \n \n BEST_EFFORT_RELIABILITY_QOS\n \n\n \n 10\n 1\n 1\n \n \n \n\n \n\n" }; #define PERFTEST_QOS_STRING_asString(str) {\ int i;\ diff --git a/srcCpp03/RTIDDSImpl.cxx b/srcCpp03/RTIDDSImpl.cxx index 350e466f..f7d0d308 100755 --- a/srcCpp03/RTIDDSImpl.cxx +++ b/srcCpp03/RTIDDSImpl.cxx @@ -2958,6 +2958,142 @@ template class RTIDDSImpl; #endif #endif // RTI_FLATDATA_AVAILABLE +PerftestDDSPrinter::PerftestDDSPrinter(): + participant(dds::core::null), + perftestInfoWriter(dds::core::null) +{ + topicName = std::string("PerftestInfo"); +} + +void PerftestDDSPrinter::initialize(ParameterManager *_PM) +{ + PerftestPrinter::initialize(_PM); + this->_PM = _PM; + topicName = std::string("PerftestInfo"); +} + +void PerftestDDSPrinter::initialize_dds_entities() +{ + dds::core::QosProvider qosProvider(dds::core::null); + + if (!_PM->get("noXmlQos")) { + qosProvider = dds::core::QosProvider( + _PM->get("qosFile"), + _PM->get("qosLibrary") + "::LoggingQos"); + } else { + rti::core::QosProviderParams perftestQosProviderParams; + dds::core::StringSeq perftestStringProfile( + PERFTEST_QOS_STRING, + PERFTEST_QOS_STRING + PERFTEST_QOS_STRING_SIZE); + perftestQosProviderParams.string_profile(perftestStringProfile); + + qosProvider = dds::core::QosProvider::Default(); + qosProvider->provider_params(perftestQosProviderParams); + qosProvider->default_library(_PM->get("qosLibrary")); + qosProvider->default_profile("LoggingQos"); + } + + dds::domain::qos::DomainParticipantQos dpQos = qosProvider.participant_qos(); + dds::pub::qos::PublisherQos publisherQos = qosProvider.publisher_qos(); + dds::pub::qos::DataWriterQos dwQos = qosProvider.datawriter_qos(); + + //TODO: Decide if we want to use the same domain or + 1 or what. + participant = dds::domain::DomainParticipant(_PM->get("domain") + 1,dpQos); + + dds::pub::Publisher publisher(participant, publisherQos); + + dds::topic::Topic topic(participant, topicName); + + perftestInfoWriter = dds::pub::DataWriter(publisher, topic, dwQos); + + if (_PM->get("pub")) { + PerftestLatencyInfo myLatencyInfo; + perftestInfo.latencyInfo(myLatencyInfo); + perftestInfo.latencyInfo().get().pubId(_PM->get("pidMultiPubTest")); + } else { + PerftestThroughputInfo myThroughputInfo; + perftestInfo.throughputInfo(myThroughputInfo); + perftestInfo.throughputInfo().get().subId(_PM->get("sidMultiSubTest")); + } + + fprintf(stderr, + "[Info] Publishing latency/throughput information via DDS\n"); +} + +void PerftestDDSPrinter::finalize() +{ + participant.close(); +} + +void PerftestDDSPrinter::print_latency_interval(LatencyInfo latencyInfo) +{ + this->dataWrapperLatency(latencyInfo); + perftestInfoWriter->write(perftestInfo); +} + +void PerftestDDSPrinter::print_throughput_interval(ThroughputInfo throughputInfo) +{ + this->dataWrapperThroughput(throughputInfo); + perftestInfoWriter->write(perftestInfo); +} + +void PerftestDDSPrinter::dataWrapperLatency(LatencyInfo latencyInfo) +{ + if (this->_dataLength != perftestInfo.dataLength()) { + perftestInfo.dataLength(_dataLength); + } + + if (this->_showCPU) { + perftestInfo.outputCpu(latencyInfo.outputCpu); + } + perftestInfo.latencyInfo().get().latency(latencyInfo.latency); + perftestInfo.latencyInfo().get().average(latencyInfo.average); + perftestInfo.latencyInfo().get().std(latencyInfo.std); + perftestInfo.latencyInfo().get().minimum(latencyInfo.minimum); + perftestInfo.latencyInfo().get().maximum(latencyInfo.maximum); + // summary part + if (!latencyInfo.interval) { + perftestInfo.latencyInfo().get().percentile50(latencyInfo.percentile50); + perftestInfo.latencyInfo().get().percentile90(latencyInfo.percentile90); + perftestInfo.latencyInfo().get().percentile99(latencyInfo.percentile99); + perftestInfo.latencyInfo().get().percentile9999(latencyInfo.percentile9999); + perftestInfo.latencyInfo().get().percentile999999(latencyInfo.percentile999999); + if (_printSerialization) { + perftestInfo.latencyInfo().get().serializeTime(latencyInfo.serializeTime); + perftestInfo.latencyInfo().get().deserializeTime(latencyInfo.deserializeTime); + } + } else { + perftestInfo.latencyInfo().get().percentile50(0); + perftestInfo.latencyInfo().get().percentile90(0); + perftestInfo.latencyInfo().get().percentile99(0); + perftestInfo.latencyInfo().get().percentile9999(0); + perftestInfo.latencyInfo().get().percentile999999(0); + perftestInfo.latencyInfo().get().serializeTime(0); + perftestInfo.latencyInfo().get().deserializeTime(0); + } +} + +void PerftestDDSPrinter::dataWrapperThroughput(ThroughputInfo throughputInfo) +{ + if (this->_dataLength != perftestInfo.dataLength()) { + perftestInfo.dataLength(_dataLength); + } + if (this->_showCPU) { + perftestInfo.outputCpu(throughputInfo.outputCpu); + } + perftestInfo.throughputInfo().get().packets(throughputInfo.packets); + perftestInfo.throughputInfo().get().packetsAverage(throughputInfo.packetsAverage); + perftestInfo.throughputInfo().get().mbps(throughputInfo.mbps); + perftestInfo.throughputInfo().get().mbpsAverage(throughputInfo.mbpsAve); + perftestInfo.throughputInfo().get().lostPackets(throughputInfo.lostPackets); + perftestInfo.throughputInfo().get().lostPacketsPercent(throughputInfo.lostPacketsPercent); + if (throughputInfo.interval) { + perftestInfo.throughputInfo().get().packetsPerSecond(throughputInfo.packetsPerSecond); + } else { + perftestInfo.throughputInfo().get().packetsPerSecond(0); + } +} + #if defined RTI_WIN32 || defined(RTI_INTIME) #pragma warning(pop) #endif diff --git a/srcCpp03/RTIDDSImpl.h b/srcCpp03/RTIDDSImpl.h index 5f72aa8c..426e2eff 100644 --- a/srcCpp03/RTIDDSImpl.h +++ b/srcCpp03/RTIDDSImpl.h @@ -11,6 +11,7 @@ #include "perftest.hpp" #include "MessagingIF.h" #include +#include "PerftestPrinter.h" #ifdef RTI_SECURE_PERFTEST #include "security/security_default.h" #endif @@ -195,4 +196,49 @@ class RTIDDSImpl : public IMessaging }; #endif // RTI_FLATDATA_AVAILABLE +class PerftestDDSPrinter: public PerftestPrinter { +public: + int domain; + std::string topicName; + + ParameterManager *_PM; + dds::domain::DomainParticipant participant; + dds::pub::DataWriter perftestInfoWriter; + PerftestInfo perftestInfo; + + PerftestDDSPrinter(); + + ~PerftestDDSPrinter() {}; + + void initialize(ParameterManager *_PM); + void initialize_dds_entities(); + void finalize(); + + void print_initial_output() + { + initialize_dds_entities(); + }; + void print_final_output() + { + finalize(); + }; + + void print_latency_header() {}; + void print_latency_interval(LatencyInfo latencyInfo); + void print_latency_summary(LatencyInfo latencyInfo) + { + print_latency_interval(latencyInfo); + }; + + void print_throughput_header() {}; + void print_throughput_interval(ThroughputInfo throughputInfo); + void print_throughput_summary(ThroughputInfo throughputInfo) + { + print_throughput_interval(throughputInfo); + }; + + void dataWrapperLatency(LatencyInfo latencyInfo); + void dataWrapperThroughput(ThroughputInfo throughputInfo); +}; + #endif // __RTIDDSIMPL_H__ diff --git a/srcCpp03/perftest_cpp.h b/srcCpp03/perftest_cpp.h index c54d8499..8036f88b 100755 --- a/srcCpp03/perftest_cpp.h +++ b/srcCpp03/perftest_cpp.h @@ -85,7 +85,9 @@ class perftest_cpp // Private members ParameterManager _PM; - PerftestPrinter _printer; + PerftestPrinter *_printer; + ThroughputInfo _throughputInfo; + LatencyInfo _latencyInfo; unsigned long long _SpinLoopCount; unsigned long _SleepNanosec; IMessaging *_MessagingImpl; diff --git a/srcCpp03/perftest_publisher.cxx b/srcCpp03/perftest_publisher.cxx index ad5f46c9..21bdbbc7 100755 --- a/srcCpp03/perftest_publisher.cxx +++ b/srcCpp03/perftest_publisher.cxx @@ -171,8 +171,6 @@ int perftest_cpp::Run(int argc, char *argv[]) { return -1; } - _printer.initialize(&_PM); - mask = (_PM.get("unbounded") != 0) << 0; mask += _PM.get("keyed") << 1; mask += _PM.get("flatdata") << 2; @@ -240,6 +238,18 @@ int perftest_cpp::Run(int argc, char *argv[]) { return -1; } + std::string outputFormat = _PM.get("outputFormat"); + if (outputFormat == "csv") { + _printer = new PerftestCSVPrinter(); + } else if (outputFormat == "json") { + _printer = new PerftestJSONPrinter(); + } else if (outputFormat == "legacy") { + _printer = new PerftestLegacyPrinter(); + } else if (outputFormat == "dds") { + _printer = new PerftestDDSPrinter(); + } + _printer->initialize(&_PM); + PrintConfiguration(); if (_PM.get("pub")) { @@ -309,7 +319,8 @@ void perftest_cpp::PrintVersion() perftest_cpp::perftest_cpp() : _SpinLoopCount(0), _SleepNanosec(0), - _MessagingImpl(NULL) + _MessagingImpl(NULL), + _printer(NULL) { /** We use rand to generate the key of a SHMEM segment when * we estimate the maximum buffer size for SHMEM @@ -332,6 +343,10 @@ perftest_cpp::~perftest_cpp() { RTIHighResolutionClock_delete(perftest_cpp::_Clock); } + if (_printer != NULL) { + delete _printer; + } + } catch (const std::exception& ex) { // This will catch DDS exceptions std::cerr << "[Error] Exception in perftest_cpp::~perftest_cpp(): " @@ -714,6 +729,8 @@ class ThroughputListener: public IMessagingCB { int subID; bool printIntervals; bool showCpu; + ThroughputInfo _throughputInfo; + public: @@ -728,7 +745,6 @@ class ThroughputListener: public IMessagingCB { unsigned long long interval_bytes_received; unsigned long long interval_missing_packets; unsigned long long interval_time, begin_time; - float missing_packets_percent; IMessagingWriter *_writer; IMessagingReader *_reader; @@ -743,7 +759,7 @@ class ThroughputListener: public IMessagingCB { ThroughputListener( ParameterManager &PM, - PerftestPrinter &printer, + PerftestPrinter *printer, IMessagingWriter *writer, IMessagingReader *reader = NULL, bool UseCft = false, @@ -758,7 +774,6 @@ class ThroughputListener: public IMessagingCB { interval_missing_packets(0), interval_time(0), begin_time(0), - missing_packets_percent(0.0), _writer(writer), _reader(reader), _last_seq_num(numPublishers), @@ -770,7 +785,10 @@ class ThroughputListener: public IMessagingCB { end_test = false; _PM = &PM; - _printer = &printer; + _printer = printer; + + _throughputInfo.dataLength = _printer->_dataLength; + _throughputInfo.outputCpu = 0.0; printIntervals = !_PM->get("noPrintIntervals"); showCpu = _PM->get("cpu"); @@ -853,8 +871,7 @@ class ThroughputListener: public IMessagingCB { begin_time = perftest_cpp::GetTimeUsec(); - _printer->set_data_length(message.size - + perftest_cpp::OVERHEAD_BYTES); + _printer->_dataLength = message.size + perftest_cpp::OVERHEAD_BYTES; _printer->print_throughput_header(); } @@ -903,29 +920,21 @@ class ThroughputListener: public IMessagingCB { interval_bytes_received = bytes_received; interval_missing_packets = missing_packets; interval_data_length = last_data_length; - missing_packets_percent = 0.0; - - // Calculations of missing package percent - if (interval_packets_received + interval_missing_packets != 0) { - missing_packets_percent = (float) ((interval_missing_packets * 100.0) - / (float) (interval_packets_received - + interval_missing_packets)); - } - double outputCpu = 0.0; if (showCpu) { - outputCpu = cpu.get_cpu_average(); + _throughputInfo.outputCpu = cpu.get_cpu_average(); cpu = CpuMonitor(); cpu.initialize(); } - _printer->print_throughput_summary( - interval_data_length + perftest_cpp::OVERHEAD_BYTES, + + _throughputInfo.set_summary( interval_packets_received, interval_time, interval_bytes_received, - interval_missing_packets, - missing_packets_percent, - outputCpu); + interval_missing_packets); + + _printer->print_throughput_summary(_throughputInfo); + } else if (endTest) { fprintf(stderr, "\n[Info] No samples have been received by the Subscriber side,\n" @@ -1064,7 +1073,7 @@ int perftest_cpp::RunSubscriber() std::cerr << "[Info] Waiting for data ..." << std::endl; // For Json format, print brackets at init - _printer.print_initial_output(); + _printer->print_initial_output(); // wait for data unsigned long long prev_time = 0, now = 0, delta = 0; @@ -1075,7 +1084,6 @@ int perftest_cpp::RunSubscriber() unsigned long long mps = 0, bps = 0; double mps_ave = 0.0, bps_ave = 0.0; unsigned long long msgsent, bytes, last_msgs, last_bytes; - float missing_packets_percent = 0.0; if (showCpu) { reader_listener->cpu.initialize(); @@ -1131,36 +1139,25 @@ int perftest_cpp::RunSubscriber() bps_ave = bps_ave + (double) (bps - bps_ave) / (double) ave_count; mps_ave = mps_ave + (double) (mps - mps_ave) / (double) ave_count; - // Calculations of missing package percent - if (last_msgs + reader_listener->missing_packets == 0) { - missing_packets_percent = 0.0; - } else { - missing_packets_percent = (float) - ((reader_listener->missing_packets * 100.0) - / (float) (last_msgs + reader_listener->missing_packets)); - } - if (last_msgs > 0) { - double outputCpu = 0.0; if (showCpu) { - outputCpu = reader_listener->cpu.get_cpu_instant(); + _throughputInfo.outputCpu = reader_listener->cpu.get_cpu_instant(); } - _printer.print_throughput_interval( + _throughputInfo.set_interval( last_msgs, mps, mps_ave, bps, bps_ave, - reader_listener->missing_packets, - missing_packets_percent, - outputCpu); + reader_listener->missing_packets); + _printer->print_throughput_interval(_throughputInfo); } } } perftest_cpp::MilliSleep(1000); - _printer.print_final_output(); + _printer->print_final_output(); if (receiverThread != NULL) { RTIOsapiThread_delete(receiverThread); } @@ -1259,6 +1256,7 @@ class LatencyListener : public IMessagingCB int subID; bool printIntervals; bool showCpu; + LatencyInfo _latencyInfo; public: IMessagingReader *_reader; @@ -1269,7 +1267,7 @@ class LatencyListener : public IMessagingCB IMessagingReader *reader, IMessagingWriter *writer, ParameterManager &PM, - PerftestPrinter &printer) + PerftestPrinter *printer) { latency_sum = 0; latency_sum_square = 0; @@ -1308,7 +1306,10 @@ class LatencyListener : public IMessagingCB _reader = reader; _writer = writer; _PM = &PM; - _printer = &printer; + _printer = printer; + + _latencyInfo.dataLength = _printer->_dataLength; + _latencyInfo.outputCpu = 0.0; subID = _PM->get("sidMultiSubTest"); printIntervals = !_PM->get("noPrintIntervals"); @@ -1330,7 +1331,6 @@ class LatencyListener : public IMessagingCB unsigned int usec; double latency_ave; double latency_std; - double outputCpu = 0.0; now = perftest_cpp::GetTimeUsec(); @@ -1413,8 +1413,8 @@ class LatencyListener : public IMessagingCB if (last_data_length != message.size) { last_data_length = message.size; - _printer->set_data_length(last_data_length - + perftest_cpp::OVERHEAD_BYTES); + _printer->_dataLength = + last_data_length + perftest_cpp::OVERHEAD_BYTES; _printer->print_latency_header(); } else { if (printIntervals) { @@ -1423,15 +1423,16 @@ class LatencyListener : public IMessagingCB (double)latency_sum_square / (double)count - (latency_ave * latency_ave)); if (showCpu) { - outputCpu = cpu.get_cpu_instant(); + _latencyInfo.outputCpu = cpu.get_cpu_instant(); } - _printer->print_latency_interval( + _latencyInfo.set_interval( latency, latency_ave, latency_std, latency_min, - latency_max, - outputCpu); + latency_max); + + _printer->print_latency_interval(_latencyInfo); } } @@ -1443,7 +1444,6 @@ class LatencyListener : public IMessagingCB void print_summary_latency(bool endTest = false) { double latency_ave; double latency_std; - double outputCpu = 0.0; if (count == 0) { if (endTest) { @@ -1476,19 +1476,22 @@ class LatencyListener : public IMessagingCB / (double)count - (latency_ave * latency_ave)); if (showCpu) { - outputCpu = cpu.get_cpu_average(); + _latencyInfo.outputCpu = cpu.get_cpu_average(); cpu = CpuMonitor(); cpu.initialize(); } - _printer->print_latency_summary( + _latencyInfo.set_summary( latency_ave, latency_std, latency_min, latency_max, _latency_history, count, - outputCpu); + 0.0, + 0.0); + + _printer->print_latency_summary(_latencyInfo); latency_sum = 0; latency_sum_square = 0; @@ -1723,7 +1726,7 @@ int perftest_cpp::RunPublisher() std::cerr << "[Info] Publishing data ..." << std::endl; - _printer.print_initial_output(); + _printer->print_initial_output(); // Set data size, account for other bytes in message message.size = (int)_PM.get("dataLen") - OVERHEAD_BYTES; @@ -2034,7 +2037,7 @@ int perftest_cpp::RunPublisher() } // For Json format, print last brackets - _printer.print_final_output(); + _printer->print_final_output(); if (_testCompleted) { // Delete timeout thread if (executionTimeoutThread != NULL) { diff --git a/srcCpp03/qos_string.h b/srcCpp03/qos_string.h index 99d58f93..6afda79a 100644 --- a/srcCpp03/qos_string.h +++ b/srcCpp03/qos_string.h @@ -1,6 +1,6 @@ #include #define PERFTEST_QOS_STRING_SIZE 46 -#define PERFTEST_QOS_STRING_TOTAL_SIZE 46411 +#define PERFTEST_QOS_STRING_TOTAL_SIZE 46893 const char * PERFTEST_QOS_STRING[PERFTEST_QOS_STRING_SIZE] = { "\n\n\n\n\n\n\n\n\n\n \n\n \n \n \n\n \n\n \n \n \n 4096\n\n \n 64\n \n 512\n \n\n \n\n \n\n \n \n\n \n \n dds.participant.property_validation_action\n 1\n \n\n ", " \n \n dds.transport.UDPv4.builtin.parent.message_size_max\n 65536\n \n \n dds.transport.UDPv4.builtin.send_socket_buffer_size\n 1048576\n \n \n dds.transport.UDPv4.builtin.recv_socket_buffer_size\n 2097152\n \n\n \n\n \n \n dds.transport.TCPv4.tcp1.library\n nddstransporttcp\n \n \n dds.transport.TCPv4.tcp1.create_function\n NDDS_Transport_TCPv4_create\n \n \n dds.transport.TCPv4.tcp1.disable_nagle\n 1\n \n \n dds.transport.TCPv4.tcp1.parent.message_size_max\n 65536\n \n\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.max_tokens\n 300\n \n ", -" \n dds.flow_controller.token_bucket.10Gbps.token_bucket.tokens_added_per_period\n 200\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.max_tokens\n 30\n \n \n dds.flow_controller.token_bucket.1G", -"bps.token_bucket.tokens_added_per_period\n 20\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n\n \n \n PerfTest Participant\n \n\n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n DURATION_ZERO_SEC\n 100000\n \n \n \n\n \n\n \n\n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n\n \n \n \n 256\n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n \n \n \n\n \n\n \n\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n \n \n \n DURATION_ZERO_SEC\n 1000000\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n\n \n LENGTH_UNLIMITED\n\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n \n\n \n \n false\n\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n false\n \n\n \n false\n \n\n \n\n \n\n \n \n\n \n \n KEEP_ALL_HISTORY_QOS\n", -" \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n\n \n \n 10000\n 128\n\n \n 10000\n \n\n \n \n 10000\n\n \n 65536\n \n\n \n ", -" \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC", -"\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n\n \n \n \n\n \n \n\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n LENGTH_UNLIMITED\n 100\n LENGTH_UNLIMITED\n \n \n \n \n \n 10\n 100\n 1000\n \n DURATION_ZERO_SEC\n 10000000\n \n \n DURATION_ZERO_SEC\n 1000000\n \n \n DURATION_ZERO_SEC\n 10000000\n \n LENGTH_UNLIMITED\n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n <", -"/max_nack_response_delay>\n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n \n \n\n \n false\n \n\n \n\n\n \n \n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n \n \n \n 100\n 100\n 100\n \n\n \n 100\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC", -"\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n \n\n \n \n \n\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE", -"_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n \n \n\n" }; +"ent>\n \n dds.transport.shmem.builtin.received_message_count_max\n 128\n \n \n dds.transport.shmem.builtin.receive_buffer_size\n 2097152\n \n -->\n\n \n \n dds.transport.TCPv4.tcp1.library\n nddstransporttcp\n \n \n dds.transport.TCPv4.tcp1.create_function\n NDDS_Transport_TCPv4_create\n \n \n dds.transport.TCPv4.tcp1.disable_nagle\n 1\n \n \n dds.transport.TCPv4.tcp1.parent.message_size_max\n 65536\n \n\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.max_tokens\n 300\n \n ", +" \n dds.flow_controller.token_bucket.10Gbps.token_bucket.tokens_added_per_period\n 200\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.10Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.max_tokens\n 30\n \n \n dds.flow_controller.token_bucket.1Gbps.t", +"oken_bucket.tokens_added_per_period\n 20\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.bytes_per_token\n 65536\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.sec\n 0\n \n \n dds.flow_controller.token_bucket.1Gbps.token_bucket.period.nanosec\n 10000000\n \n\n \n \n\n \n \n PerfTest Participant\n \n\n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n\n \n \n \n \n TOPIC_PRESENTATION_QOS\n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n DURATION_ZERO_SEC\n 100000\n \n \n \n\n \n\n \n\n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n\n \n \n \n 256\n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n \n \n \n\n \n\n \n\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n \n \n \n DURATION_ZERO_SEC\n 1000000\n \n\n \n \n DURATION_ZERO_SEC\n 10000000\n \n\n \n LENGTH_UNLIMITED\n\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n \n\n \n \n false\n\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n\n \n false\n \n\n \n false\n \n\n \n\n \n\n \n \n\n \n \n KEEP_ALL_HISTORY_QOS\n ", +" \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n\n \n \n 10000\n 128\n\n \n 10000\n \n\n \n \n 10000", +"\n\n \n 65536\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n ", +" \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n\n \n\n\n \n \n \n\n \n \n\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n\n \n \n \n \n LENGTH_UNLIMITED\n 100\n LENGTH_UNLIMITED\n \n \n \n \n \n 10\n 100\n 1000\n \n DURATION_ZERO_SEC\n 10000000\n \n \n DURATION_ZERO_SEC\n 1000000\n \n \n DURATION_ZERO_SEC\n 10000000\n \n LENGTH_UNLIMITED\n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n LENGTH_UNLIMITED\n LENGTH_UNLIMITED\n \n \n\n \n false\n \n\n \n\n\n \n \n \n \n RELIABLE_RELIABILITY_QOS\n \n\n \n \n \n \n 100\n 100\n 100\n \n\n \n 100\n \n\n \n \n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n ", +" \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n DURATION_ZERO_SEC\n DURATION_ZERO_NSEC\n \n \n \n \n \n\n \n \n \n\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n\n \n\n \n \n RELIABLE_RELIABILITY_QOS\n \n DURATION_INFINITE_SEC\n DURATION_INFINITE_NSEC", +"\n \n \n \n \n KEEP_ALL_HISTORY_QOS\n \n \n DDS_TRANSIENT_LOCAL_DURABILITY_QOS\n \n \n \n\n \n\n \n\n \n \n BEST_EFFORT_RELIABILITY_QOS\n \n\n \n 10\n 1\n 1\n \n \n \n\n \n\n" }; #define PERFTEST_QOS_STRING_asString(str) {\ int i;\ diff --git a/srcCppCommon/ParameterManager.cxx b/srcCppCommon/ParameterManager.cxx index b3e29605..505e8c13 100644 --- a/srcCppCommon/ParameterManager.cxx +++ b/srcCppCommon/ParameterManager.cxx @@ -345,12 +345,14 @@ void ParameterManager::initialize() " - 'csv'\n" " - 'json'\n" " - 'legacy'\n" + " - 'dds'\n" "Default: 'csv'"); outputFormat->set_type(T_STR); outputFormat->set_extra_argument(YES); outputFormat->add_valid_str_value("legacy"); outputFormat->add_valid_str_value("json"); outputFormat->add_valid_str_value("csv"); + outputFormat->add_valid_str_value("dds"); outputFormat->set_group(GENERAL); outputFormat->set_supported_middleware( Middleware::RTIDDSPRO diff --git a/srcCppCommon/PerftestPrinter.cxx b/srcCppCommon/PerftestPrinter.cxx index 0fa3da86..5e39c0f5 100644 --- a/srcCppCommon/PerftestPrinter.cxx +++ b/srcCppCommon/PerftestPrinter.cxx @@ -5,492 +5,505 @@ #include "PerftestPrinter.h" -PerftestPrinter::PerftestPrinter() - : _dataLength(100), _printSummaryHeaders(true), _outputFormat(CSV) +void ThroughputInfo::set_interval( + unsigned long long packets, + unsigned long long packetsPerSecond, + double packetsAverage, + unsigned long long bps, + double bpsAve, + unsigned long long lostPackets) { + this->packets = packets; + this->packetsPerSecond = packetsPerSecond; + this->packetsAverage = packetsAverage; + this->mbps = bps * 8.0 / 1000.0 / 1000.0; + this->mbpsAve = bpsAve * 8.0 / 1000.0 / 1000.0; + this->lostPackets = lostPackets; + // Calculations of missing package percent + if (packets + lostPackets != 0) { + this->lostPacketsPercent = (float) ((lostPackets * 100.0) + / (float) (packets + lostPackets)); + } else { + this->lostPacketsPercent = 0.0; + } + this->interval = true; } -void PerftestPrinter::initialize(ParameterManager *_PM) +void ThroughputInfo::set_summary( + unsigned long long packets, + unsigned long long time, + unsigned long long bytes, + unsigned long long lostPackets) { - std::string outputFormat = _PM->get("outputFormat"); - _printIntervals = !_PM->get("noPrintIntervals"); - _printHeaders = !_PM->get("noOutputHeaders"); - _printSerialization = _PM->get("serializationTime"); - _showCPU = _PM->get("cpu"); - if (outputFormat == "csv") { - _outputFormat = CSV; - } else if (outputFormat == "json") { - _outputFormat = JSON; - _isJsonInitialized = false; - } else if (outputFormat == "legacy") { - _outputFormat = LEGACY; + this->packets = packets; + this->packetsPerSecond = packets * 1000000 / time; + this->mbpsAve = bytes * 1000000.0 / time * 8.0 / 1000.0 + / 1000.0; + this->lostPackets = lostPackets; + if (packets + lostPackets != 0) { + this->lostPacketsPercent = (float) ((lostPackets * 100.0) + / (float) (packets + lostPackets)); + } else { + this->lostPacketsPercent = 0.0; } + this->interval = false; } +void LatencyInfo::set_interval( + unsigned long latency, + double average, + double std, + unsigned long minimum, + unsigned long maximum) +{ + this->latency = latency; + this->average = average; + this->std = std; + this->minimum = minimum; + this->maximum = maximum; + this->interval = true; +} -void PerftestPrinter::set_data_length(unsigned int dataLength) +void LatencyInfo::set_summary( + double average, + double std, + unsigned long minimum, + unsigned long maximum, + unsigned long *history, + unsigned long long count, + double serializeTime, + double deserializeTime) { - _dataLength = dataLength; + this->average = average; + this->std = std; + this->minimum = minimum; + this->maximum = maximum; + this->percentile50 = history[count * 50 / 100]; + this->percentile90 = history[count * 90 / 100]; + this->percentile99 = history[count * 99 / 100]; + this->percentile9999 = history[count * 9999 / 10000]; + this->percentile999999 = history[count * 999999 / 1000000]; + this->serializeTime = serializeTime; + this->deserializeTime = deserializeTime; + this->interval = false; } -void PerftestPrinter::set_header_printed(bool printHeaders) +void PerftestPrinter::initialize(ParameterManager *_PM) { - _printHeaders = printHeaders; + _printIntervals = !_PM->get("noPrintIntervals"); + _printHeaders = !_PM->get("noOutputHeaders"); + _printSerialization = _PM->get("serializationTime"); + _showCPU = _PM->get("cpu"); } -void PerftestPrinter::print_latency_header() +/******************************************************************************/ +/* CSV Implementation */ +/******************************************************************************/ + +void PerftestCSVPrinter::print_latency_header() { - switch (_outputFormat) { - case CSV: - if (_printHeaders && _printIntervals) { - printf("\nIntervals One-way Latency for %d Bytes:\n", _dataLength); - printf("Length (Bytes)" - ", Latency (" PERFT_TIME_UNIT - "), Ave (" PERFT_TIME_UNIT - "), Std (" PERFT_TIME_UNIT - "), Min (" PERFT_TIME_UNIT - "), Max (" PERFT_TIME_UNIT ")"); - if (_showCPU) { - printf(", CPU (%%)"); - } - printf("\n"); - } - break; - case JSON: - if (_isJsonInitialized) { - printf(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; + if (_printHeaders && _printIntervals) { + printf("\nIntervals One-way Latency for %d Bytes:\n", _dataLength); + printf("Length (Bytes)" + ", Latency (" PERFT_TIME_UNIT + "), Ave (" PERFT_TIME_UNIT + "), Std (" PERFT_TIME_UNIT + "), Min (" PERFT_TIME_UNIT + "), Max (" PERFT_TIME_UNIT ")"); + if (_showCPU) { + printf(", CPU (%%)"); } - printf("\t\t\t\"length\":%d,\n", _dataLength); + printf("\n"); + } +} - if (_printIntervals) { - printf("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - break; - case LEGACY: - if (_printHeaders && _printIntervals) { - printf("\n\n********** New data length is %d\n", _dataLength); +void PerftestCSVPrinter::print_throughput_header() +{ + if (_printHeaders && _printIntervals) { + printf("\nInterval Throughput for %d Bytes:\n", _dataLength); + printf("Length (Bytes), Total Samples, Samples/s," + " Ave Samples/s, Mbps, Ave Mbps" + ", Lost Samples, Lost Samples (%%)"); + if (_showCPU) { + printf(", CPU (%%)"); } - break; + printf("\n"); } } -void PerftestPrinter::print_throughput_header() +void PerftestCSVPrinter::print_latency_interval(LatencyInfo latencyInfo) { - switch (_outputFormat) { - case CSV: - if (_printHeaders && _printIntervals) { - printf("\nInterval Throughput for %d Bytes:\n", _dataLength); - printf("Length (Bytes), Total Samples, Samples/s," - " Ave Samples/s, Mbps, Ave Mbps" - ", Lost Samples, Lost Samples (%%)"); - if (_showCPU) { - printf(", CPU (%%)"); - } - printf("\n"); - } - break; - case JSON: - if (_isJsonInitialized) { - printf(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; - } - printf("\t\t\t\"length\":%d,\n", _dataLength); - if (_printIntervals) { - printf("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - break; - case LEGACY: - if (_printHeaders && _printIntervals) { - printf("\n\n********** New data length is %d\n", _dataLength); - } - break; + printf("%14d,%13llu,%9.0lf,%9.1lf,%9llu,%9llu", + _dataLength, + latencyInfo.latency, + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum); + if (_showCPU) { + printf(",%8.2f", latencyInfo.outputCpu); } + printf("\n"); } -void PerftestPrinter::print_latency_interval( - unsigned long latency, - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - double outputCpu) +void PerftestCSVPrinter::print_latency_summary(LatencyInfo latencyInfo) { - switch (_outputFormat) { - case CSV: - printf("%14d,%13lu,%9.0lf,%9.1lf,%9lu,%9lu", - _dataLength, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - printf(",%8.2f", outputCpu); + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; } - printf("\n"); - break; - case JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - printf(","); + if (_printIntervals) { + printf("\nOne-way Latency Summary:\n"); } - printf("\n\t\t\t\t{\n" - "\t\t\t\t\t\"latency\": %lu,\n" - "\t\t\t\t\t\"latency_ave\": %1.2lf,\n" - "\t\t\t\t\t\"latency_std\": %1.2lf,\n" - "\t\t\t\t\t\"latency_min\": %lu,\n" - "\t\t\t\t\t\"latency_max\": %lu", - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - printf(",\n\t\t\t\t\t\"cpu\": %1.2f", outputCpu); + printf("Length (Bytes)" + ", Ave (" PERFT_TIME_UNIT + "), Std (" PERFT_TIME_UNIT + "), Min (" PERFT_TIME_UNIT + "), Max (" PERFT_TIME_UNIT + "), 50%% (" PERFT_TIME_UNIT + "), 90%% (" PERFT_TIME_UNIT + "), 99%% (" PERFT_TIME_UNIT + "), 99.99%% (" PERFT_TIME_UNIT + "), 99.9999%% (" PERFT_TIME_UNIT + ")"); + if (_printSerialization) { + printf(", Serialization (" PERFT_TIME_UNIT + "), Deserialization (" PERFT_TIME_UNIT + "), Total (" PERFT_TIME_UNIT ")"); } - printf("\n\t\t\t\t}"); - break; - case LEGACY: - printf("One way Latency: %6lu " PERFT_TIME_UNIT - " Ave %6.0lf " PERFT_TIME_UNIT - " Std %6.1lf " PERFT_TIME_UNIT - " Min %6lu " PERFT_TIME_UNIT - " Max %6lu " PERFT_TIME_UNIT, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); if (_showCPU) { - printf(" CPU %1.2f (%%)", outputCpu); + printf(", CPU (%%)"); } printf("\n"); - break; } + printf("%14d,%9.0lf,%9.1lf,%9llu,%9llu,%9llu,%9llu,%9llu,%12llu,%14llu", + _dataLength, + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum, + latencyInfo.percentile50, + latencyInfo.percentile90, + latencyInfo.percentile99, + latencyInfo.percentile9999, + latencyInfo.percentile999999); + if (_printSerialization) { + printf(",%19.3f,%21.3f,%11.3f", + latencyInfo.serializeTime, + latencyInfo.deserializeTime, + latencyInfo.serializeTime + latencyInfo.deserializeTime); + } + if (_showCPU) { + printf(",%8.2f", latencyInfo.outputCpu); + } + printf("\n"); } -void PerftestPrinter::print_latency_summary( - int totalSampleSize, - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - unsigned long *latencyHistory, - unsigned long long count, - double serializeTime, - double deserializeTime, - double outputCpu) +void PerftestCSVPrinter::print_throughput_interval(ThroughputInfo throughputInfo) { - switch (_outputFormat) { - case CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - printf("\nOne-way Latency Summary:\n"); - printf("Length (Bytes)" - ", Ave (" PERFT_TIME_UNIT - "), Std (" PERFT_TIME_UNIT - "), Min (" PERFT_TIME_UNIT - "), Max (" PERFT_TIME_UNIT - "), 50%% (" PERFT_TIME_UNIT - "), 90%% (" PERFT_TIME_UNIT - "), 99%% (" PERFT_TIME_UNIT - "), 99.99%% (" PERFT_TIME_UNIT - "), 99.9999%% (" PERFT_TIME_UNIT - ")"); - if (_printSerialization) { - printf(", Serialization (" PERFT_TIME_UNIT - "), Deserialization (" PERFT_TIME_UNIT - "), Total (" PERFT_TIME_UNIT ")"); - } - if (_showCPU) { - printf(", CPU (%%)"); - } - printf("\n"); - } - printf("%14d,%9.0lf,%9.1lf,%9lu,%9lu,%9lu,%9lu,%9lu,%12lu,%14lu", - totalSampleSize, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count * (9999.0 / 10000))], - latencyHistory[(int) (count * (999999.0 / 1000000))]); - if (_printSerialization) { - printf(",%19.3f,%21.3f,%11.3f", - serializeTime, - deserializeTime, - serializeTime + deserializeTime); - } - if (_showCPU) { - printf(",%8.2f", outputCpu); + printf("%14d,%14llu,%11llu,%14.0lf,%9.1lf,%10.1lf, %12llu, %16.2lf", + _dataLength, + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.packetsAverage, + throughputInfo.mbps, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(",%8.2f", throughputInfo.outputCpu); + } + printf("\n"); +} + +void PerftestCSVPrinter::print_throughput_summary(ThroughputInfo throughputInfo) +{ + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; } - printf("\n"); - break; - case JSON: if (_printIntervals) { - printf("\n\t\t\t],\n"); - } - printf("\t\t\t\"summary\":{\n" - "\t\t\t\t\"latency_ave\": %1.2lf,\n" - "\t\t\t\t\"latency_std\": %1.2lf,\n" - "\t\t\t\t\"latency_min\": %lu,\n" - "\t\t\t\t\"latency_max\": %lu,\n" - "\t\t\t\t\"latency_50\": %lu,\n" - "\t\t\t\t\"latency_90\": %lu,\n" - "\t\t\t\t\"latency_99\": %lu,\n" - "\t\t\t\t\"latency_99.99\": %lu,\n" - "\t\t\t\t\"latency_99.9999\": %lu", - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count * (9999.0 / 10000))], - latencyHistory[(int) (count * (999999.0 / 1000000))]); - if (_printSerialization) { - printf(",\n\t\t\t\t\"serialize\": %1.3f,\n" - "\t\t\t\t\"deserialize\": %1.3f,\n" - "\t\t\t\t\"total_s\": %1.3f", - serializeTime, - deserializeTime, - serializeTime + deserializeTime); - } - if (_showCPU) { - printf(",\n\t\t\t\t\"cpu\": %1.2f", outputCpu); + printf("\nThroughput Summary:\n"); } - printf("\n\t\t\t}\n\t\t}"); - break; - case LEGACY: - printf("Length: %5d" - " Latency: Ave %6.0lf " PERFT_TIME_UNIT - " Std %6.1lf " PERFT_TIME_UNIT - " Min %6lu " PERFT_TIME_UNIT - " Max %6lu " PERFT_TIME_UNIT - " 50%% %6lu " PERFT_TIME_UNIT - " 90%% %6lu " PERFT_TIME_UNIT - " 99%% %6lu " PERFT_TIME_UNIT - " 99.99%% %6lu " PERFT_TIME_UNIT - " 99.9999%% %6lu " PERFT_TIME_UNIT, - totalSampleSize, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count * (9999.0 / 10000))], - latencyHistory[(int) (count * (999999.0 / 1000000))]); + printf("Length (Bytes), Total Samples, Ave Samples/s," + " Ave Mbps, Lost Samples, Lost Samples (%%)"); if (_showCPU) { - printf(" CPU %1.2f (%%)", outputCpu); + printf(", CPU (%%)"); } printf("\n"); - if (_printSerialization) { - printf("Serialization/Deserialization: %0.3f us / %0.3f us / " - "TOTAL: " - "%0.3f us\n", - serializeTime, - deserializeTime, - serializeTime + deserializeTime); - } - break; } + printf("%14d,%14llu,%14.0llu,%12.1lf, %12llu, %16.2lf", + _dataLength, + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(",%8.2f", throughputInfo.outputCpu); + } + printf("\n"); } -void PerftestPrinter::print_latency_summary( - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - unsigned long *latencyHistory, - unsigned long long count, - double outputCpu) +/******************************************************************************/ +/* JSON Implementation */ +/******************************************************************************/ + +void PerftestJSONPrinter::print_latency_header() +{ + if (_isJsonInitialized) { + printf(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; + } + printf("\t\t\t\"length\":%d,\n", _dataLength); + + if (_printIntervals) { + printf("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; + } +} + +void PerftestJSONPrinter::print_throughput_header() +{ + if (_isJsonInitialized) { + printf(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; + } + printf("\t\t\t\"length\":%d,\n", _dataLength); + if (_printIntervals) { + printf("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; + } +} + +void PerftestJSONPrinter::print_latency_interval(LatencyInfo latencyInfo) { - this->print_latency_summary( + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + printf(","); + } + printf("\n\t\t\t\t{\n" + "\t\t\t\t\t\"latency\": %llu,\n" + "\t\t\t\t\t\"latency_ave\": %1.2lf,\n" + "\t\t\t\t\t\"latency_std\": %1.2lf,\n" + "\t\t\t\t\t\"latency_min\": %llu,\n" + "\t\t\t\t\t\"latency_max\": %llu", + latencyInfo.latency, + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum); + if (_showCPU) { + printf(",\n\t\t\t\t\t\"cpu\": %1.2f", latencyInfo.outputCpu); + } + printf("\n\t\t\t\t}"); +} + +void PerftestJSONPrinter::print_latency_summary(LatencyInfo latencyInfo) +{ + if (_printIntervals) { + printf("\n\t\t\t],\n"); + } + printf("\t\t\t\"summary\":{\n" + "\t\t\t\t\"latency_ave\": %1.2lf,\n" + "\t\t\t\t\"latency_std\": %1.2lf,\n" + "\t\t\t\t\"latency_min\": %llu,\n" + "\t\t\t\t\"latency_max\": %llu,\n" + "\t\t\t\t\"latency_50\": %llu,\n" + "\t\t\t\t\"latency_90\": %llu,\n" + "\t\t\t\t\"latency_99\": %llu,\n" + "\t\t\t\t\"latency_99.99\": %llu,\n" + "\t\t\t\t\"latency_99.9999\": %llu", + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum, + latencyInfo.percentile50, + latencyInfo.percentile90, + latencyInfo.percentile99, + latencyInfo.percentile9999, + latencyInfo.percentile999999); + if (_printSerialization) { + printf(",\n\t\t\t\t\"serialize\": %1.3f,\n" + "\t\t\t\t\"deserialize\": %1.3f,\n" + "\t\t\t\t\"total_s\": %1.3f", + latencyInfo.serializeTime, + latencyInfo.deserializeTime, + latencyInfo.serializeTime + latencyInfo.deserializeTime); + } + if (_showCPU) { + printf(",\n\t\t\t\t\"cpu\": %1.2f", latencyInfo.outputCpu); + } + printf("\n\t\t\t}\n\t\t}"); +} + +void PerftestJSONPrinter::print_throughput_interval(ThroughputInfo throughputInfo) +{ + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + printf(","); + } + printf("\n\t\t\t\t{\n" + "\t\t\t\t\t\"length\": %d,\n" + "\t\t\t\t\t\"packets\": %llu,\n" + "\t\t\t\t\t\"packets/s\": %llu,\n" + "\t\t\t\t\t\"packets/s_ave\": %1.2lf,\n" + "\t\t\t\t\t\"mbps\": %1.1lf,\n" + "\t\t\t\t\t\"mbps_ave\": %1.1lf,\n" + "\t\t\t\t\t\"lost\": %llu,\n" + "\t\t\t\t\t\"lost_percent\": %1.2lf", _dataLength, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory, - count, - -1, - -1, - outputCpu - ); + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.packetsAverage, + throughputInfo.mbps, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(",\n\t\t\t\t\t\"cpu\": %1.2f", throughputInfo.outputCpu); + } + printf("\n\t\t\t\t}"); } -void PerftestPrinter::print_throughput_interval( - unsigned long long lastMsgs, - unsigned long long mps, - double mpsAve, - unsigned long long bps, - double bpsAve, - unsigned long long missingPackets, - float missingPacketsPercent, - double outputCpu) +void PerftestJSONPrinter::print_throughput_summary(ThroughputInfo throughputInfo) { - switch (_outputFormat) { - case CSV: - printf("%14d,%14llu,%11llu,%14.0lf,%9.1lf,%10.1lf, %12llu, %16.2lf", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(",%8.2f", outputCpu); - } - printf("\n"); - break; + if (_printIntervals) { + printf("\t\t\t],\n"); + } + printf("\t\t\t\"summary\":{\n" + "\t\t\t\t\"packets\": %llu,\n" + "\t\t\t\t\"packets/sAve\": %llu,\n" + "\t\t\t\t\"mbpsAve\": %1.1lf,\n" + "\t\t\t\t\"lost\": %llu,\n" + "\t\t\t\t\"lostPercent\": %1.2lf", + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(",\n\t\t\t\t\"cpu\": %1.2f", throughputInfo.outputCpu); + } + printf("\n\t\t\t}\n\t\t}"); +} - case JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - printf(","); - } - printf("\n\t\t\t\t{\n" - "\t\t\t\t\t\"length\": %d,\n" - "\t\t\t\t\t\"packets\": %llu,\n" - "\t\t\t\t\t\"packets/s\": %llu,\n" - "\t\t\t\t\t\"packets/s_ave\": %1.2lf,\n" - "\t\t\t\t\t\"mbps\": %1.1lf,\n" - "\t\t\t\t\t\"mbps_ave\": %1.1lf,\n" - "\t\t\t\t\t\"lost\": %llu,\n" - "\t\t\t\t\t\"lost_percent\": %1.2lf", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(",\n\t\t\t\t\t\"cpu\": %1.2f", outputCpu); - } - printf("\n\t\t\t\t}"); - break; - case LEGACY: - printf("Packets: %8llu Packets/s: %7llu Packets/s(ave): %7.0lf " - "Mbps: %7.1lf Mbps(ave): %7.1lf Lost: %5llu (%1.2f%%)", - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(" CPU %1.2f (%%)", outputCpu); - } - printf("\n"); - break; +void PerftestJSONPrinter::print_initial_output() +{ + printf("{\"perftest\":\n\t[\n\t\t{\n"); +} + +void PerftestJSONPrinter::print_final_output() +{ + printf("\n\t]\n}\n"); +} + + +/******************************************************************************/ +/* LEGACY Implementation */ +/******************************************************************************/ + +void PerftestLegacyPrinter::print_latency_header() +{ + if (_printHeaders && _printIntervals) { + printf("\n\n********** New data length is %d\n", _dataLength); } } -void PerftestPrinter::print_throughput_summary( - int length, - unsigned long long intervalPacketsReceived, - unsigned long long intervalTime, - unsigned long long intervalBytesReceived, - unsigned long long intervalMissingPackets, - float missingPacketsPercent, - double outputCpu) +void PerftestLegacyPrinter::print_throughput_header() { - switch (_outputFormat) { - case CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - printf("\nThroughput Summary:\n"); - printf("Length (Bytes), Total Samples, Ave Samples/s," - " Ave Mbps, Lost Samples, Lost Samples (%%)"); - if (_showCPU) { - printf(", CPU (%%)"); - } - printf("\n"); - } - printf("%14d,%14llu,%14.0llu,%12.1lf, %12llu, %16.2lf", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000 / intervalTime, - intervalBytesReceived * 1000000.0 / intervalTime * 8.0 / 1000.0 - / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(",%8.2f", outputCpu); - } - printf("\n"); - break; - case JSON: - if (_printIntervals) { - printf("\t\t\t],\n"); - } - printf("\t\t\t\"summary\":{\n" - "\t\t\t\t\"packets\": %llu,\n" - "\t\t\t\t\"packets/sAve\": %llu,\n" - "\t\t\t\t\"mbpsAve\": %1.1lf,\n" - "\t\t\t\t\"lost\": %llu,\n" - "\t\t\t\t\"lostPercent\": %1.2lf", - intervalPacketsReceived, - intervalPacketsReceived * 1000000 / intervalTime, - intervalBytesReceived * 1000000.0 / intervalTime * 8.0 / 1000.0 - / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(",\n\t\t\t\t\"cpu\": %1.2f", outputCpu); - } - printf("\n\t\t\t}\n\t\t}"); - break; - case LEGACY: - printf("Length: %5d Packets: %8llu Packets/s(ave): %7llu " - "Mbps(ave): %7.1lf Lost: %5llu (%1.2f%%)", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000 / intervalTime, - intervalBytesReceived * 1000000.0 / intervalTime * 8.0 / 1000.0 - / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - printf(" CPU %1.2f (%%)", outputCpu); - } - printf("\n"); - break; + if (_printHeaders && _printIntervals) { + printf("\n\n********** New data length is %d\n", _dataLength); } } -void PerftestPrinter::print_initial_output() +void PerftestLegacyPrinter::print_latency_interval(LatencyInfo latencyInfo) { - if (_outputFormat == JSON) { - printf("{\"perftest\":\n\t[\n\t\t{\n"); + printf("One way Latency: %6llu " PERFT_TIME_UNIT + " Ave %6.0lf " PERFT_TIME_UNIT + " Std %6.1lf " PERFT_TIME_UNIT + " Min %6llu " PERFT_TIME_UNIT + " Max %6llu " PERFT_TIME_UNIT, + latencyInfo.latency, + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum); + if (_showCPU) { + printf(" CPU %1.2f (%%)", latencyInfo.outputCpu); } + printf("\n"); } -void PerftestPrinter::print_final_output() +void PerftestLegacyPrinter::print_latency_summary(LatencyInfo latencyInfo) { - if (_outputFormat == JSON) { - printf("\n\t]\n}\n"); + printf("Length: %5d" + " Latency: Ave %6.0lf " PERFT_TIME_UNIT + " Std %6.1lf " PERFT_TIME_UNIT + " Min %6llu " PERFT_TIME_UNIT + " Max %6llu " PERFT_TIME_UNIT + " 50%% %6llu " PERFT_TIME_UNIT + " 90%% %6llu " PERFT_TIME_UNIT + " 99%% %6llu " PERFT_TIME_UNIT + " 99.99%% %6llu " PERFT_TIME_UNIT + " 99.9999%% %6llu " PERFT_TIME_UNIT, + _dataLength, + latencyInfo.average, + latencyInfo.std, + latencyInfo.minimum, + latencyInfo.maximum, + latencyInfo.percentile50, + latencyInfo.percentile90, + latencyInfo.percentile99, + latencyInfo.percentile9999, + latencyInfo.percentile999999); + if (_showCPU) { + printf(" CPU %1.2f (%%)", latencyInfo.outputCpu); + } + printf("\n"); + if (_printSerialization) { + printf("Serialization/Deserialization: %0.3f us / %0.3f us / " + "TOTAL: " + "%0.3f us\n", + latencyInfo.serializeTime, + latencyInfo.deserializeTime, + latencyInfo.serializeTime + latencyInfo.deserializeTime); } -} \ No newline at end of file +} + +void PerftestLegacyPrinter::print_throughput_interval(ThroughputInfo throughputInfo) +{ + printf("Packets: %8llu Packets/s: %7llu Packets/s(ave): %7.0lf " + "Mbps: %7.1lf Mbps(ave): %7.1lf Lost: %5llu (%1.2f%%)", + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.packetsAverage, + throughputInfo.mbps, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(" CPU %1.2f (%%)", throughputInfo.outputCpu); + } + printf("\n"); +} + +void PerftestLegacyPrinter::print_throughput_summary(ThroughputInfo throughputInfo) +{ + printf("Length: %5d Packets: %8llu Packets/s(ave): %7llu " + "Mbps(ave): %7.1lf Lost: %5llu (%1.2f%%)", + _dataLength, + throughputInfo.packets, + throughputInfo.packetsPerSecond, + throughputInfo.mbpsAve, + throughputInfo.lostPackets, + throughputInfo.lostPacketsPercent); + if (_showCPU) { + printf(" CPU %1.2f (%%)", throughputInfo.outputCpu); + } + printf("\n"); +} diff --git a/srcCppCommon/PerftestPrinter.h b/srcCppCommon/PerftestPrinter.h index 84d8a901..824ae4ca 100644 --- a/srcCppCommon/PerftestPrinter.h +++ b/srcCppCommon/PerftestPrinter.h @@ -16,89 +16,154 @@ #include #include "ParameterManager.h" -enum PerftestOuputFormat { LEGACY, JSON, CSV }; +struct ThroughputInfo { + unsigned long dataLength; + unsigned long long packets; + unsigned long long packetsPerSecond; + double packetsAverage; + double mbps; + double mbpsAve; + unsigned long long lostPackets; + float lostPacketsPercent; + bool interval; + double outputCpu; + + void set_interval( + unsigned long long packets, + unsigned long long packetsPerSecond, + double packetsAverage, + unsigned long long bps, + double bpsAve, + unsigned long long lostPackets); + + void set_summary( + unsigned long long packets, + unsigned long long time, + unsigned long long bytes, + unsigned long long lostPackets); +}; +struct LatencyInfo { + unsigned long dataLength; + unsigned long long latency; + double average; + double std; + unsigned long long minimum; + unsigned long long maximum; + unsigned long long percentile50; + unsigned long long percentile90; + unsigned long long percentile99; + unsigned long long percentile9999; + unsigned long long percentile999999; + double serializeTime; + double deserializeTime; + bool interval; + double outputCpu; + + void set_interval( + unsigned long latency, + double average, + double std, + unsigned long minimum, + unsigned long maximum); + + void set_summary( + double average, + double std, + unsigned long minimum, + unsigned long maximum, + unsigned long *history, + unsigned long long count, + double serializeTime, + double deserializeTime); +}; class PerftestPrinter { -private: - unsigned int _dataLength; - bool _printHeaders; + +protected: bool _showCPU; bool _printIntervals; bool _printSummaryHeaders; bool _printSerialization; - bool _isJsonInitialized; - bool _controlJsonIntervals; - PerftestOuputFormat _outputFormat; public: - PerftestPrinter(); - ~PerftestPrinter() - { - } + unsigned int _dataLength; + bool _printHeaders; - void initialize(ParameterManager *_PM); + PerftestPrinter() {_dataLength = 100; _printSummaryHeaders = true;} + virtual ~PerftestPrinter() {}; - // Set and Get members - void set_data_length(unsigned int dataLength); + virtual void initialize(ParameterManager *_PM); - void set_header_printed(bool printHeaders); + virtual void print_latency_header() = 0; - // Methods - void print_latency_header(); + virtual void print_latency_interval(LatencyInfo latencyInfo) = 0; - void print_latency_interval( - unsigned long latency, - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - double outputCpu); - - void print_latency_summary( - int totalSampleSize, - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - unsigned long *latencyHistory, - unsigned long long count, - double serializeTime, - double deserializeTime, - double outputCpu); - - void print_latency_summary( - double latencyAve, - double latencyStd, - unsigned long latencyMin, - unsigned long latencyMax, - unsigned long *latencyHistory, - unsigned long long count, - double outputCpu); + virtual void print_latency_summary(LatencyInfo latencyInfo) = 0; + + virtual void print_throughput_header() = 0; + + virtual void print_throughput_interval(ThroughputInfo throughputInfo) = 0; + + virtual void print_throughput_summary(ThroughputInfo throughputInfo) = 0; + + virtual void print_initial_output() {}; + + virtual void print_final_output() {}; +}; + +class PerftestCSVPrinter : public PerftestPrinter { +public: + ~PerftestCSVPrinter() {}; + void print_latency_header(); + void print_latency_interval(LatencyInfo latencyInfo); + void print_latency_summary(LatencyInfo latencyInfo); void print_throughput_header(); + void print_throughput_interval(ThroughputInfo throughputInfo); + void print_throughput_summary(ThroughputInfo throughputInfo); +}; - void print_throughput_interval( - unsigned long long lastMsgs, - unsigned long long mps, - double mpsAve, - unsigned long long bps, - double bpsAve, - unsigned long long missingPackets, - float missingPacketsPercent, - double outputCpu); - - void print_throughput_summary( - int length, - unsigned long long intervalPacketsReceived, - unsigned long long intervalTime, - unsigned long long intervalBytesReceived, - unsigned long long intervalMissingPackets, - float missingPacketsPercent, - double outputCpu); +class PerftestJSONPrinter : public PerftestPrinter { - void print_initial_output(); +private: + bool _isJsonInitialized; + bool _controlJsonIntervals; +public: + + void initialize(ParameterManager *_PM) + { + PerftestPrinter::initialize(_PM); + _isJsonInitialized = false; + _controlJsonIntervals = false; + }; + + ~PerftestJSONPrinter() {}; + void print_latency_header(); + void print_latency_interval(LatencyInfo latencyInfo); + void print_latency_summary(LatencyInfo latencyInfo); + void print_throughput_header(); + void print_throughput_interval(ThroughputInfo throughputInfo); + void print_throughput_summary(ThroughputInfo throughputInfo); + void print_initial_output(); void print_final_output(); }; + +class PerftestLegacyPrinter: public PerftestPrinter { + + ~PerftestLegacyPrinter() {}; + void print_latency_header(); + void print_latency_interval(LatencyInfo latencyInfo); + void print_latency_summary(LatencyInfo latencyInfo); + + void print_throughput_header(); + void print_throughput_interval(ThroughputInfo throughputInfo); + void print_throughput_summary(ThroughputInfo throughputInfo); + + void print_initial_output() {}; + + void print_final_output() {}; +}; + #endif // __PERFTESTPRINTER_H__ diff --git a/srcCs/PerftestPrinter.cs b/srcCs/PerftestPrinter.cs index f4d59cff..4d7e4f3c 100644 --- a/srcCs/PerftestPrinter.cs +++ b/srcCs/PerftestPrinter.cs @@ -3,140 +3,305 @@ using System.Text; namespace PerformanceTest { - enum PerftestOutputFormat + public abstract class PerftestPrinter { - LEGACY, - JSON, - CSV - } - public class PerftestPrinter - { - private int _dataLength; - private bool _printHeaders; - private bool _showCPU; - private bool _printIntervals; - private bool _printSummaryHeaders; - private bool _isJsonInitialized; - private bool _controlJsonIntervals; - private PerftestOutputFormat _outputFormat; + public int _dataLength; + public bool _printHeaders; + protected bool _showCPU; + protected bool _printIntervals; + protected bool _printSummaryHeaders; public const string PERFT_TIME_UNIT = "us"; public PerftestPrinter() { _dataLength = 100; _printSummaryHeaders = true; - _outputFormat = PerftestOutputFormat.CSV; } - public void initialize( + public virtual void initialize( bool printIntervals, - string outputFormat, bool printHeaders, bool showCpu) { _printIntervals = printIntervals; _printHeaders = printHeaders; _showCPU = showCpu; - if (outputFormat.Equals("csv")) { - _outputFormat = PerftestOutputFormat.CSV; - } else if (outputFormat.Equals("json")) { - _outputFormat = PerftestOutputFormat.JSON; - _isJsonInitialized = false; - } else if (outputFormat.Equals("legacy")) { - _outputFormat = PerftestOutputFormat.LEGACY; + } + public abstract void print_latency_header(); + public abstract void print_throughput_header(); + public abstract void print_latency_interval( + uint latency, + double latencyAve, + double latencyStd, + uint latencyMin, + uint latencyMax, + double outputCpu); + public abstract void print_latency_summary( + double latencyAve, + double latencyStd, + ulong latencyMin, + ulong latencyMax, + uint[] latencyHistory, + ulong count, + double outputCpu); + public abstract void print_throughput_interval( + ulong lastMsgs, + ulong mps, + double mpsAve, + ulong bps, + double bpsAve, + ulong missingPackets, + double missingPacketsPercent, + double outputCpu); + public abstract void print_throughput_summary( + int length, + ulong intervalPacketsReceived, + ulong intervalTime, + ulong intervalBytesReceived, + ulong intervalMissingPackets, + double missingPacketsPercent, + double outputCpu); + public virtual void print_initial_output() + { + } + public virtual void print_final_output() + { + } + } + + public class PerftestCSVPrinter : PerftestPrinter + { + public PerftestCSVPrinter() + { + _dataLength = 100; + _printSummaryHeaders = true; + } + public override void print_latency_header() + { + if(_printHeaders && _printIntervals) { + Console.Write("\nIntervals One-way Latency for {0} " + + "Bytes:\n", _dataLength); + Console.Write("Length (Bytes)" + + ", Latency ({0}" + + "), Ave ({0}" + + "), Std ({0}" + + "), Min ({0}" + + "), Max ({0})", + PERFT_TIME_UNIT); } + if (_showCPU) { + Console.Write(", CPU (%)"); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_throughput_header() + { + if(_printHeaders && _printIntervals) { + Console.Write("\nIntervals Throughput for {0} " + + "Bytes:\n", _dataLength); + Console.Write("Length (Bytes), Total Samples, " + + "Samples/s, Ave Samples/s, " + + "Mbps, Ave Mbps" + + ", Lost Samples, Lost Samples (%)"); + } + if (_showCPU) { + Console.Write(", CPU (%)"); + } + Console.Write("\n"); + Console.Out.Flush(); } - public void set_data_length(int dataLength) + public override void print_latency_interval( + uint latency, + double latencyAve, + double latencyStd, + uint latencyMin, + uint latencyMax, + double outputCpu) { - _dataLength = dataLength; + Console.Write("{0,14},{1,13},{2,9:F0},{3,9:F1},{4,9},{5,9}", + _dataLength, + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + Console.Write(",{0,8:F2}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); } - public void set_header_printed(bool printHeaders) + public override void print_latency_summary( + double latencyAve, + double latencyStd, + ulong latencyMin, + ulong latencyMax, + uint[] latencyHistory, + ulong count, + double outputCpu) { + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; + } + if (_printIntervals) { + Console.Write("\nOne-way Latency Summary:\n"); + } + Console.Write("Length (Bytes)" + + ", Ave ({0}" + + "), Std ({0}" + + "), Min ({0}" + + "), Max ({0}" + + "), 50%% ({0}" + + "), 90%% ({0}" + + "), 99%% ({0}" + + "), 99.99%% ({0}" + + "), 99.9999%% ({0})", + PERFT_TIME_UNIT); + if (_showCPU) { + Console.Write(", CPU (%)"); + } + Console.Write("\n"); + } + Console.Write("{0,14},{1,9:F0},{2,9:F1},{3,9},{4,9}" + + "{5,9},{6,9},{7,9},{8,12},{9,14}", + _dataLength, + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[count * 50 / 100], + latencyHistory[count * 90 / 100], + latencyHistory[count * 99 / 100], + latencyHistory[(int) (count * + (9999.0 / 10000))], + latencyHistory[(int) (count * + (999999.0 / 1000000))]); + if (_showCPU) { + Console.Write(",{0,8:F2}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_throughput_interval( + ulong lastMsgs, + ulong mps, + double mpsAve, + ulong bps, + double bpsAve, + ulong missingPackets, + double missingPacketsPercent, + double outputCpu) + { + Console.Write("{0,14},{1,14},{2,11:F0},{3,14:F0},{4,9:F1}" + + ",{5,10:F1},{6,13},{7,17:F2}", + _dataLength, + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(",{0,8:F2}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_throughput_summary( + int length, + ulong intervalPacketsReceived, + ulong intervalTime, + ulong intervalBytesReceived, + ulong intervalMissingPackets, + double missingPacketsPercent, + double outputCpu) + { + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; + } + if (_printIntervals) { + Console.Write("\nThroughput Summary:\n"); + } + Console.Write("Length (Bytes), Total Samples," + + " Ave Samples/s, Ave Mbps, " + + "Lost Samples, Lost Samples (%)"); + if (_showCPU) { + Console.Write(", CPU (%)"); + } + Console.Write("\n"); + } + Console.Write("{0,14},{1,14},{2,14:F0},{3,12:F1}," + + "{4,13},{5,17:F2}", + length, + intervalPacketsReceived, + intervalPacketsReceived * 1000000 + / intervalTime, + intervalBytesReceived * 1000000.0 + / intervalTime * 8.0 / 1000.0 / 1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(",{0,8:F2}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + } + + public class PerftestJSONPrinter : PerftestPrinter + { + protected bool _isJsonInitialized; + protected bool _controlJsonIntervals; + + public PerftestJSONPrinter() + { + _dataLength = 100; + _printSummaryHeaders = true; + } + + public override void initialize( + bool printIntervals, + bool printHeaders, + bool showCpu) + { + _printIntervals = printIntervals; _printHeaders = printHeaders; + _showCPU = showCpu; + _isJsonInitialized = false; + _controlJsonIntervals = false; } - public void print_latency_header() + public override void print_latency_header() { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - if(_printHeaders && _printIntervals) { - Console.Write("\nIntervals One-way Latency for {0} " + - "Bytes:\n", _dataLength); - Console.Write("Length (Bytes)" + - ", Latency ({0}" + - "), Ave ({0}" + - "), Std ({0}" + - "), Min ({0}" + - "), Max ({0})", - PERFT_TIME_UNIT); - } - if (_showCPU) { - Console.Write(", CPU (%)"); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_isJsonInitialized) { - Console.Write(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; - } - Console.Write("\t\t\t\"length\":{0},\n", _dataLength); - if (_printIntervals) { - Console.Write("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - Console.Out.Flush(); - break; - case PerftestOutputFormat.LEGACY: - if(_printHeaders && _printIntervals) { - Console.Write("\n\n********** New data length is {0}\n", - _dataLength); - Console.Out.Flush(); - } - break; + if (_isJsonInitialized) { + Console.Write(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; } + Console.Write("\t\t\t\"length\":{0},\n", _dataLength); + if (_printIntervals) { + Console.Write("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; + } + Console.Out.Flush(); } - public void print_throughput_header() + public override void print_throughput_header() { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - if(_printHeaders && _printIntervals) { - Console.Write("\nIntervals Throughput for {0} " + - "Bytes:\n", _dataLength); - Console.Write("Length (Bytes), Total Samples, " + - "Samples/s, Ave Samples/s, " + - "Mbps, Ave Mbps" + - ", Lost Samples, Lost Samples (%)"); - } - if (_showCPU) { - Console.Write(", CPU (%)"); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_isJsonInitialized) { - Console.Write(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; - } - Console.Write("\t\t\t\"length\":{0},\n", _dataLength); - if (_printIntervals) { - Console.Write("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - Console.Out.Flush(); - break; - case PerftestOutputFormat.LEGACY: - if(_printHeaders && _printIntervals) { - Console.Write("\n\n********** New data length is {0}\n", - _dataLength); - Console.Out.Flush(); - } - break; + if (_isJsonInitialized) { + Console.Write(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; + } + Console.Write("\t\t\t\"length\":{0},\n", _dataLength); + if (_printIntervals) { + Console.Write("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; } + Console.Out.Flush(); } - public void print_latency_interval( + public override void print_latency_interval( uint latency, double latencyAve, double latencyStd, @@ -144,66 +309,30 @@ public void print_latency_interval( uint latencyMax, double outputCpu) { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - Console.Write("{0,14},{1,13},{2,9:F0},{3,9:F1},{4,9},{5,9}", - _dataLength, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - Console.Write(",{0,8:F2}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - Console.Write(","); - } - Console.Write("\n\t\t\t\t{{\n" + - "\t\t\t\t\t\"latency\": {0},\n" + - "\t\t\t\t\t\"latency_ave\": {1:F0},\n" + - "\t\t\t\t\t\"latency_std\": {2:F1},\n" + - "\t\t\t\t\t\"latency_min\": {3},\n" + - "\t\t\t\t\t\"latency_max\": {4}", - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - Console.Write(",\n\t\t\t\t\t\"cpu\": {0:F1}", - outputCpu); - } - Console.Write("\n\t\t\t\t}"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.LEGACY: - Console.Write("One way Latency: {1,6} {0}" + - " Ave {2,6:F0} {0}" + - " Std {3,6:F1} {0}" + - " Min {4,6} {0}" + - " Max {5,6} {0}", - PERFT_TIME_UNIT, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - Console.Write(" CPU {0:P}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + Console.Write(","); + } + Console.Write("\n\t\t\t\t{{\n" + + "\t\t\t\t\t\"latency\": {0},\n" + + "\t\t\t\t\t\"latency_ave\": {1:F0},\n" + + "\t\t\t\t\t\"latency_std\": {2:F1},\n" + + "\t\t\t\t\t\"latency_min\": {3},\n" + + "\t\t\t\t\t\"latency_max\": {4}", + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + Console.Write(",\n\t\t\t\t\t\"cpu\": {0:F1}", + outputCpu); } + Console.Write("\n\t\t\t\t}"); + Console.Out.Flush(); } - public void print_latency_summary( + public override void print_latency_summary( double latencyAve, double latencyStd, ulong latencyMin, @@ -212,112 +341,36 @@ public void print_latency_summary( ulong count, double outputCpu) { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - Console.Write("\nOne-way Latency Summary:\n"); - Console.Write("Length (Bytes)" + - ", Ave ({0}" + - "), Std ({0}" + - "), Min ({0}" + - "), Max ({0}" + - "), 50%% ({0}" + - "), 90%% ({0}" + - "), 99%% ({0}" + - "), 99.99%% ({0}" + - "), 99.9999%% ({0})", - PERFT_TIME_UNIT); - if (_showCPU) { - Console.Write(", CPU (%)"); - } - Console.Write("\n"); - } - Console.Write("{0,14},{1,9:F0},{2,9:F1},{3,9},{4,9}" + - "{5,9},{6,9},{7,9},{8,12},{9,14}", - _dataLength, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count * - (9999.0 / 10000))], - latencyHistory[(int) (count * - (999999.0 / 1000000))]); - if (_showCPU) { - Console.Write(",{0,8:F2}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_printIntervals) { - Console.Write("\n\t\t\t],\n"); - } - Console.Write("\t\t\t\"summary\":{{\n" + - "\t\t\t\t\"latency_ave\": {0:F1},\n" + - "\t\t\t\t\"latency_std\": {1:F1},\n" + - "\t\t\t\t\"latency_min\": {2},\n" + - "\t\t\t\t\"latency_max\": {3},\n" + - "\t\t\t\t\"latency_50\": {4},\n" + - "\t\t\t\t\"latency_90\": {5},\n" + - "\t\t\t\t\"latency_99\": {6},\n" + - "\t\t\t\t\"latency_99.99\": {7},\n" + - "\t\t\t\t\"latency_99.9999\": {8}", - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count * - (9999.0 / 10000))], - latencyHistory[(int) (count * - (999999.0 / 1000000))]); - if (_showCPU) { - Console.Write(",\n\t\t\t\t\"cpu\": {0:F1}", outputCpu); - } - Console.Write("\n\t\t\t}\n\t\t}"); - break; - case PerftestOutputFormat.LEGACY: - Console.Write("Length: {1,5}" + - " Latency: Ave {2,6:F0} {0}" + - " Std {3,6:F1} {0}" + - " Min {4,6} {0}" + - " Max {5,6} {0}" + - " 50% {6,6} {0}" + - " 90% {7,6} {0}" + - " 99% {8,6} {0}" + - " 99.99% {9,6} {0}" + - " 99.9999% {10,6} {0}", - PERFT_TIME_UNIT, - _dataLength, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[count * 50 / 100], - latencyHistory[count * 90 / 100], - latencyHistory[count * 99 / 100], - latencyHistory[(int) (count - * (9999.0 / 10000))], - latencyHistory[(int) (count - * (999999.0 / 1000000))]); - if (_showCPU) { - Console.Write(" CPU {0:P}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; + if (_printIntervals) { + Console.Write("\n\t\t\t],\n"); } + Console.Write("\t\t\t\"summary\":{{\n" + + "\t\t\t\t\"latency_ave\": {0:F1},\n" + + "\t\t\t\t\"latency_std\": {1:F1},\n" + + "\t\t\t\t\"latency_min\": {2},\n" + + "\t\t\t\t\"latency_max\": {3},\n" + + "\t\t\t\t\"latency_50\": {4},\n" + + "\t\t\t\t\"latency_90\": {5},\n" + + "\t\t\t\t\"latency_99\": {6},\n" + + "\t\t\t\t\"latency_99.99\": {7},\n" + + "\t\t\t\t\"latency_99.9999\": {8}", + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[count * 50 / 100], + latencyHistory[count * 90 / 100], + latencyHistory[count * 99 / 100], + latencyHistory[(int) (count * + (9999.0 / 10000))], + latencyHistory[(int) (count * + (999999.0 / 1000000))]); + if (_showCPU) { + Console.Write(",\n\t\t\t\t\"cpu\": {0:F1}", outputCpu); + } + Console.Write("\n\t\t\t}\n\t\t}"); } - public void print_throughput_interval( + public override void print_throughput_interval( ulong lastMsgs, ulong mps, double mpsAve, @@ -327,73 +380,35 @@ public void print_throughput_interval( double missingPacketsPercent, double outputCpu) { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - Console.Write("{0,14},{1,14},{2,11:F0},{3,14:F0},{4,9:F1}" + - ",{5,10:F1},{6,13},{7,17:F2}", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(",{0,8:F2}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - Console.Write(","); - } - Console.Write("\n\t\t\t\t{{\n" + - "\t\t\t\t\t\"length\": {0},\n" + - "\t\t\t\t\t\"packets\": {1},\n" + - "\t\t\t\t\t\"packets/s\": {2},\n" + - "\t\t\t\t\t\"packets/s_ave\": {3:F2},\n" + - "\t\t\t\t\t\"mbps\": {4:F1},\n" + - "\t\t\t\t\t\"mbps_ave\": {5:F1},\n" + - "\t\t\t\t\t\"lost\": {6},\n" + - "\t\t\t\t\t\"lost_percent\": {7:F2}", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(",\n\t\t\t\t\t\"cpu\": {0:F1}", - outputCpu); - } - Console.Write("\n\t\t\t\t}"); - break; - case PerftestOutputFormat.LEGACY: - Console.Write("Packets: {0,8} Packets/s: {1,7} " + - "Packets/s(ave): {2,7:F0} Mbps: {3,7:F1}" + - " Mbps(ave): {4,7:F1} Lost: {5,5} ({6:P})", - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(" CPU {0:P}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + Console.Write(","); + } + Console.Write("\n\t\t\t\t{{\n" + + "\t\t\t\t\t\"length\": {0},\n" + + "\t\t\t\t\t\"packets\": {1},\n" + + "\t\t\t\t\t\"packets/s\": {2},\n" + + "\t\t\t\t\t\"packets/s_ave\": {3:F2},\n" + + "\t\t\t\t\t\"mbps\": {4:F1},\n" + + "\t\t\t\t\t\"mbps_ave\": {5:F1},\n" + + "\t\t\t\t\t\"lost\": {6},\n" + + "\t\t\t\t\t\"lost_percent\": {7:F2}", + _dataLength, + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(",\n\t\t\t\t\t\"cpu\": {0:F1}", + outputCpu); } + Console.Write("\n\t\t\t\t}"); } - public void print_throughput_summary( + public override void print_throughput_summary( int length, ulong intervalPacketsReceived, ulong intervalTime, @@ -402,90 +417,174 @@ public void print_throughput_summary( double missingPacketsPercent, double outputCpu) { - switch (_outputFormat) { - case PerftestOutputFormat.CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - Console.Write("\nThroughput Summary:\n"); - Console.Write("Length (Bytes), Total Samples," + - " Ave Samples/s, Ave Mbps, " + - "Lost Samples, Lost Samples (%)"); - if (_showCPU) { - Console.Write(", CPU (%)"); - } - Console.Write("\n"); - } - Console.Write("{0,14},{1,14},{2,14:F0},{3,12:F1}," + - "{4,13},{5,17:F2}", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000 - / intervalTime, - intervalBytesReceived * 1000000.0 - / intervalTime * 8.0 / 1000.0 / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(",{0,8:F2}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; - case PerftestOutputFormat.JSON: - if (_printIntervals) { - Console.Write("\n\t\t\t],\n"); - } - Console.Write("\t\t\t\"summary\":{{\n" + - "\t\t\t\t\"packets\": {0},\n" + - "\t\t\t\t\"packets/sAve\": {1},\n" + - "\t\t\t\t\"mbpsAve\": {2:F1},\n" + - "\t\t\t\t\"lost\": {3},\n" + - "\t\t\t\t\"lostPercent\": {4:F2}", - intervalPacketsReceived, - intervalPacketsReceived * 1000000 - / intervalTime, - intervalBytesReceived * 1000000.0 - / intervalTime * 8.0 / 1000.0 / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(",\n\t\t\t\t\"cpu\": {0:F1}", outputCpu); - } - Console.Write("\n\t\t\t}\n\t\t}"); - break; - case PerftestOutputFormat.LEGACY: - Console.Write("Length: {0,5} Packets: {1,8} " + - "Packets/s(ave): {2,7} " + - "Mbps(ave): {3,7:F1} Lost: {4,5} ({5:P})", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000 - / intervalTime, - intervalBytesReceived * 1000000.0 - / intervalTime * 8.0 / 1000.0 / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - Console.Write(" CPU {0:P}", outputCpu); - } - Console.Write("\n"); - Console.Out.Flush(); - break; + if (_printIntervals) { + Console.Write("\n\t\t\t],\n"); } + Console.Write("\t\t\t\"summary\":{{\n" + + "\t\t\t\t\"packets\": {0},\n" + + "\t\t\t\t\"packets/sAve\": {1},\n" + + "\t\t\t\t\"mbpsAve\": {2:F1},\n" + + "\t\t\t\t\"lost\": {3},\n" + + "\t\t\t\t\"lostPercent\": {4:F2}", + intervalPacketsReceived, + intervalPacketsReceived * 1000000 + / intervalTime, + intervalBytesReceived * 1000000.0 + / intervalTime * 8.0 / 1000.0 / 1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(",\n\t\t\t\t\"cpu\": {0:F1}", outputCpu); + } + Console.Write("\n\t\t\t}\n\t\t}"); + } + public override void print_initial_output() + { + Console.Write("{\"perftest\":\n\t[\n\t\t{\n"); } - public void print_initial_output() + public override void print_final_output() { - if (_outputFormat.Equals(PerftestOutputFormat.JSON)) { - Console.Write("{\"perftest\":\n\t[\n\t\t{\n"); + Console.Write("\n\t]\n}\n"); + } + } + + public class PerftestLegacyPrinter : PerftestPrinter + { + public PerftestLegacyPrinter() + { + _dataLength = 100; + _printSummaryHeaders = true; + } + public override void print_latency_header() + { + if(_printHeaders && _printIntervals) { + Console.Write("\n\n********** New data length is {0}\n", + _dataLength); + Console.Out.Flush(); } } - public void print_final_output() + public override void print_throughput_header() + { + if(_printHeaders && _printIntervals) { + Console.Write("\n\n********** New data length is {0}\n", + _dataLength); + Console.Out.Flush(); + } + } + public override void print_latency_interval( + uint latency, + double latencyAve, + double latencyStd, + uint latencyMin, + uint latencyMax, + double outputCpu) + { + Console.Write("One way Latency: {1,6} {0}" + + " Ave {2,6:F0} {0}" + + " Std {3,6:F1} {0}" + + " Min {4,6} {0}" + + " Max {5,6} {0}", + PERFT_TIME_UNIT, + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + Console.Write(" CPU {0:P}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_latency_summary( + double latencyAve, + double latencyStd, + ulong latencyMin, + ulong latencyMax, + uint[] latencyHistory, + ulong count, + double outputCpu) + { + Console.Write("Length: {1,5}" + + " Latency: Ave {2,6:F0} {0}" + + " Std {3,6:F1} {0}" + + " Min {4,6} {0}" + + " Max {5,6} {0}" + + " 50% {6,6} {0}" + + " 90% {7,6} {0}" + + " 99% {8,6} {0}" + + " 99.99% {9,6} {0}" + + " 99.9999% {10,6} {0}", + PERFT_TIME_UNIT, + _dataLength, + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[count * 50 / 100], + latencyHistory[count * 90 / 100], + latencyHistory[count * 99 / 100], + latencyHistory[(int) (count + * (9999.0 / 10000))], + latencyHistory[(int) (count + * (999999.0 / 1000000))]); + if (_showCPU) { + Console.Write(" CPU {0:P}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_throughput_interval( + ulong lastMsgs, + ulong mps, + double mpsAve, + ulong bps, + double bpsAve, + ulong missingPackets, + double missingPacketsPercent, + double outputCpu) + { + Console.Write("Packets: {0,8} Packets/s: {1,7} " + + "Packets/s(ave): {2,7:F0} Mbps: {3,7:F1}" + + " Mbps(ave): {4,7:F1} Lost: {5,5} ({6:P})", + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(" CPU {0:P}", outputCpu); + } + Console.Write("\n"); + Console.Out.Flush(); + } + public override void print_throughput_summary( + int length, + ulong intervalPacketsReceived, + ulong intervalTime, + ulong intervalBytesReceived, + ulong intervalMissingPackets, + double missingPacketsPercent, + double outputCpu) { - if (_outputFormat.Equals(PerftestOutputFormat.JSON)) { - Console.Write("\n\t]\n}\n"); + Console.Write("Length: {0,5} Packets: {1,8} " + + "Packets/s(ave): {2,7} " + + "Mbps(ave): {3,7:F1} Lost: {4,5} ({5:P})", + length, + intervalPacketsReceived, + intervalPacketsReceived * 1000000 + / intervalTime, + intervalBytesReceived * 1000000.0 + / intervalTime * 8.0 / 1000.0 / 1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + Console.Write(" CPU {0:P}", outputCpu); } + Console.Write("\n"); + Console.Out.Flush(); } } } \ No newline at end of file diff --git a/srcCs/perftest_publisher.cs b/srcCs/perftest_publisher.cs index 8c404dd8..26809507 100755 --- a/srcCs/perftest_publisher.cs +++ b/srcCs/perftest_publisher.cs @@ -775,9 +775,16 @@ void Run(string[] argv) return; } + if ("csv".Equals(_outputFormat)) { + _printer = new PerftestCSVPrinter(); + } else if ("json".Equals(_outputFormat)) { + _printer = new PerftestJSONPrinter(); + } else if ("legacy".Equals(_outputFormat)) { + _printer = new PerftestLegacyPrinter(); + } + _printer.initialize( _PrintIntervals, - _outputFormat, _printHeaders, _showCpu); @@ -1730,7 +1737,7 @@ public void ProcessMessage(TestMessage message) } begin_time = perftest_cs.GetTimeUsec(); - _printer.set_data_length(message.size + (int) OVERHEAD_BYTES); + _printer._dataLength = message.size + (int) OVERHEAD_BYTES; _printer.print_throughput_header(); } @@ -2195,8 +2202,8 @@ public void ProcessMessage(TestMessage message) if (last_data_length != 0) { - _printer.set_data_length(last_data_length - + (int) OVERHEAD_BYTES); + _printer._dataLength = last_data_length + + (int) OVERHEAD_BYTES; _printer.print_latency_header(); } } @@ -2834,7 +2841,7 @@ public Perftest_ProductVersion_t ( private bool _displayWriterStats = false; private bool _useCft = false; private System.Timers.Timer timer = null; - private static PerftestPrinter _printer = new PerftestPrinter(); + private static PerftestPrinter _printer = null; private static int _SubID = 0; private static int _PubID = 0; private static bool _PrintIntervals = true; diff --git a/srcDoc/command_line_parameters.rst b/srcDoc/command_line_parameters.rst index 8ddcbb18..e00bf5f7 100644 --- a/srcDoc/command_line_parameters.rst +++ b/srcDoc/command_line_parameters.rst @@ -456,6 +456,9 @@ Test Parameters for Publishing and Subscribing Applications ['csv','json','legacy']. + For *C++ Traditional* and *C++ Modern* API implementation there is another format, + 'dds', using dds to send the data. + | **Default:** ``csv`` | **Values:** ``['csv','json','legacy']`` diff --git a/srcDoc/designDocuments/280-ouput-format.md b/srcDoc/designDocuments/280-ouput-format.md index f184bf42..8e7ddb52 100644 --- a/srcDoc/designDocuments/280-ouput-format.md +++ b/srcDoc/designDocuments/280-ouput-format.md @@ -9,6 +9,8 @@ The aim of this project is to change the view of all the data printed during the There are new flags for manage: - `-outputFormat {csv, json, legacy}` - `-noOutputHeaders`. Delete the row with headers of intervals and summaries. +- For *C++ Traditional* and *C++ Modern* API implementation there is another format, +'dds', using dds to send the data. Examples: diff --git a/srcDoc/release_notes.rst b/srcDoc/release_notes.rst index 0a8574a7..88df7297 100644 --- a/srcDoc/release_notes.rst +++ b/srcDoc/release_notes.rst @@ -138,6 +138,9 @@ output format by using the `-outputFormat `. At this point the supported values are `csv` (default), `json` or `legacy` (Referring to the previous output used by *RTI Perftest*. +For *C++ Traditional* and *C++ Modern* there is one more type support, `dds`. It send +all test data using dds instead of show in terminal. + Another flag has been added, `-noOutputHeaders`, in order to skip printing the headers rows (for the summaries and also for the interval information). diff --git a/srcIdl/perftest.idl b/srcIdl/perftest.idl index 1b12de13..c463ddab 100644 --- a/srcIdl/perftest.idl +++ b/srcIdl/perftest.idl @@ -182,3 +182,38 @@ struct TestDataKeyedLarge_FlatData_t { }; #endif // RTI_FLATDATA_AVAILABLE + +// Generate this type in order to propagate information about rti perftest when +// using output = dds +struct PerftestThroughputInfo { + @key long subId; + @optional unsigned long long packets; + @optional unsigned long long packetsPerSecond; + @optional double packetsAverage; + @optional double mbps; + @optional double mbpsAverage; + @optional unsigned long long lostPackets; + @optional float lostPacketsPercent; +}; +struct PerftestLatencyInfo { + @key long pubId; + @optional unsigned long long latency; + @optional double average; + @optional double std; + @optional unsigned long long minimum; + @optional unsigned long long maximum; + @optional unsigned long long percentile50; + @optional unsigned long long percentile90; + @optional unsigned long long percentile99; + @optional unsigned long long percentile9999; + @optional unsigned long long percentile999999; + @optional double serializeTime; + @optional double deserializeTime; +}; + +struct PerftestInfo { + @key unsigned long dataLength; + @optional PerftestLatencyInfo latencyInfo; + @optional PerftestThroughputInfo throughputInfo; + @optional double outputCpu; +}; diff --git a/srcJava/com/rti/perftest/harness/LatencyListener.java b/srcJava/com/rti/perftest/harness/LatencyListener.java index 8de9a83f..8dfe5f4a 100644 --- a/srcJava/com/rti/perftest/harness/LatencyListener.java +++ b/srcJava/com/rti/perftest/harness/LatencyListener.java @@ -9,7 +9,10 @@ import static java.lang.Math.sqrt; import java.util.Arrays; -import com.rti.perftest.harness.PerfTest; +import com.rti.perftest.harness.PerftestPrinter; +import com.rti.perftest.harness.PerftestCSVPrinter; +import com.rti.perftest.harness.PerftestJSONPrinter; +import com.rti.perftest.harness.PerftestLegacyPrinter; import com.rti.perftest.IMessagingCB; import com.rti.perftest.IMessagingReader; import com.rti.perftest.IMessagingWriter; @@ -155,7 +158,7 @@ public void processMessage(TestMessage message) { _latencySum += latency; _latencySumSquare += ((long)latency * (long)latency); - double outputCpu = 0; + double outputCpu = 0.0; if (PerfTest._showCpu) { outputCpu = CpuMonitor.get_cpu_instant(); } @@ -163,8 +166,8 @@ public void processMessage(TestMessage message) { // if data sized changed if (_lastDataLength != message.size) { _lastDataLength = message.size; - PerfTest._printer.set_data_length(message.size + - PerfTest.OVERHEAD_BYTES); + PerfTest._printer._dataLength = message.size + + PerfTest.OVERHEAD_BYTES; PerfTest._printer.print_latency_header(); } else if (PerfTest.printIntervals) { @@ -217,7 +220,7 @@ public void print_summary_latency(boolean endTest) { double latency_std = sqrt( abs(_latencySumSquare / (double)_count - (latency_ave * latency_ave))); - double outputCpu = 0; + double outputCpu = 0.0; if (PerfTest._showCpu) { outputCpu = CpuMonitor.get_cpu_average(); } diff --git a/srcJava/com/rti/perftest/harness/PerfTest.java b/srcJava/com/rti/perftest/harness/PerfTest.java index fa8ef9e8..fdb77c6d 100644 --- a/srcJava/com/rti/perftest/harness/PerfTest.java +++ b/srcJava/com/rti/perftest/harness/PerfTest.java @@ -89,7 +89,7 @@ public final class PerfTest { static boolean _printHeaders = true; static String _outputFormat = "csv"; - public static PerftestPrinter _printer = new PerftestPrinter(); + public static PerftestPrinter _printer = null; // ----------------------------------------------------------------------- // Private Fields @@ -225,9 +225,16 @@ private void run(IMessaging messagingImpl, return; } + if ("json".equals(_outputFormat)) { + _printer = new PerftestJSONPrinter(); + } else if ("legacy".equals(_outputFormat)) { + _printer = new PerftestLegacyPrinter(); + } else { + _printer = new PerftestCSVPrinter(); + } + _printer.initialize( printIntervals, - _outputFormat, _printHeaders, _showCpu); diff --git a/srcJava/com/rti/perftest/harness/PerftestCSVPrinter.java b/srcJava/com/rti/perftest/harness/PerftestCSVPrinter.java new file mode 100644 index 00000000..30653c8c --- /dev/null +++ b/srcJava/com/rti/perftest/harness/PerftestCSVPrinter.java @@ -0,0 +1,184 @@ +package com.rti.perftest.harness; + +public class PerftestCSVPrinter extends PerftestPrinter { + @Override + public void print_latency_header() + { + if(_printHeaders && _printIntervals) { + System.out.printf("\nIntervals One-way Latency for %1d " + + "Bytes:\n", _dataLength); + System.out.printf("Length (Bytes)" + + ", Latency (" + PERFT_TIME_UNIT + + "), Ave (" + PERFT_TIME_UNIT + + "), Std (" + PERFT_TIME_UNIT + + "), Min (" + PERFT_TIME_UNIT + + "), Max (" + PERFT_TIME_UNIT + + ")"); + if (_showCPU) { + System.out.print(", CPU (%%)"); + } + } + System.out.print("\n"); + System.out.flush(); + } + @Override + public void print_throughput_header() + { + if(_printHeaders && _printIntervals) { + System.out.printf("\nIntervals Throughput for %1d " + + "Bytes:\n", _dataLength); + System.out.printf("Length (Bytes), Total Samples, " + + "Samples/s, Ave Samples/s, " + + "Mbps, Ave Mbps" + + ", Lost Samples, Lost Samples (%%)"); + if (_showCPU) { + System.out.printf(", CPU (%%)"); + } + } + System.out.printf("\n"); + System.out.flush(); + } + @Override + public void print_latency_interval( + int latency, + double latencyAve, + double latencyStd, + int latencyMin, + int latencyMax, + double outputCpu) + { + System.out.printf("%1$14d,%2$13d,%3$9.0f,%4$9.1f,%5$9d" + + ",%6$9d", + _dataLength, + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + System.out.printf(",%1$8.2f", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + public void print_latency_summary( + double latencyAve, + double latencyStd, + long latencyMin, + long latencyMax, + int[] latencyHistory, + long count, + double outputCpu) + { + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; + } + if (_printIntervals) { + System.out.printf("\nOne-way Latency Summary:\n"); + } + System.out.printf("Length (Bytes)" + + ", Ave (" + PERFT_TIME_UNIT + + "), Std (" + PERFT_TIME_UNIT + + "), Min (" + PERFT_TIME_UNIT + + "), Max (" + PERFT_TIME_UNIT + + "), 50%% (" + PERFT_TIME_UNIT + + "), 90%% (" + PERFT_TIME_UNIT + + "), 99%% (" + PERFT_TIME_UNIT + + "), 99.99%% (" + PERFT_TIME_UNIT + + "), 99.9999%% (" +PERFT_TIME_UNIT + + ")"); + if (_showCPU) { + System.out.printf(", CPU (%%)"); + } + System.out.printf("\n"); + } + System.out.printf("%1$14d,%2$9.0f,%3$9.1f,%4$9d,%5$9d," + + "%6$9d,%7$9d,%8$9d,%9$12d,%10$14d", + _dataLength, + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[(int) (count * 50 / 100)], + latencyHistory[(int) (count * 90 / 100)], + latencyHistory[(int) (count * 99 / 100)], + latencyHistory[(int) (count * + (9999 / 10000))], + latencyHistory[(int) (count * + (999999 / 1000000))]); + if (_showCPU) { + System.out.printf(",%1$8.2f", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + @Override + public void print_throughput_interval( + long lastMsgs, + long mps, + double mpsAve, + long bps, + double bpsAve, + long missingPackets, + double missingPacketsPercent, + double outputCpu) + { + System.out.printf("%1$14d,%2$14d,%3$11d,%4$14.0f,%5$9.1f"+ + ",%6$10.1f,%7$13d,%8$17.2f", + _dataLength, + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(",%1$8.2f", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + @Override + public void print_throughput_summary( + int length, + long intervalPacketsReceived, + long intervalTime, + long intervalBytesReceived, + long intervalMissingPackets, + double missingPacketsPercent, + double outputCpu) + { + if (_printSummaryHeaders && _printHeaders) { + if (!_printIntervals && _printSummaryHeaders) { + _printSummaryHeaders = _printIntervals; + } + if (_printIntervals) { + System.out.printf("\nThroughput Summary:\n"); + } + System.out.printf("Length (Bytes), Total Samples," + + " Ave Samples/s, Ave Mbps, " + + "Lost Samples, Lost Samples (%%)"); + if (_showCPU) { + System.out.printf(", CPU (%%)"); + } + System.out.printf("\n"); + } + System.out.printf("%1$14d,%2$14d,%3$14.0f,%4$12.1f," + + "%5$13d,%6$17.2f", + length, + intervalPacketsReceived, + intervalPacketsReceived * 1000000.0 + / intervalTime, + intervalBytesReceived * 1000000.0 + / intervalTime * 8.0 / 1000.0 / 1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(",%1$8.2f", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } +} diff --git a/srcJava/com/rti/perftest/harness/PerftestJSONPrinter.java b/srcJava/com/rti/perftest/harness/PerftestJSONPrinter.java new file mode 100644 index 00000000..5ebf5116 --- /dev/null +++ b/srcJava/com/rti/perftest/harness/PerftestJSONPrinter.java @@ -0,0 +1,204 @@ +package com.rti.perftest.harness; + +public class PerftestJSONPrinter extends PerftestPrinter{ + + private boolean _isJsonInitialized; + private boolean _controlJsonIntervals; + + @Override + public void initialize( + boolean printIntervals, + boolean printHeaders, + boolean showCpu) + { + super.initialize(printIntervals, printHeaders, showCpu); + _isJsonInitialized = false; + _controlJsonIntervals = false; + } + + @Override + public void print_latency_header() + { + if (_isJsonInitialized) { + System.out.print(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; + } + System.out.printf("\t\t\t\"length\":%1d,\n", _dataLength); + if (_printIntervals) { + System.out.print("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; + } + System.out.flush(); + } + + @Override + public void print_throughput_header() + { + if (_isJsonInitialized) { + System.out.printf(",\n\t\t{\n"); + } else { + _isJsonInitialized = true; + } + System.out.printf("\t\t\t\"length\":%1d,\n", _dataLength); + if (_printIntervals) { + System.out.printf("\t\t\t\"intervals\":[\n"); + _controlJsonIntervals = true; + } + System.out.flush(); + } + + @Override + public void print_latency_interval( + int latency, + double latencyAve, + double latencyStd, + int latencyMin, + int latencyMax, + double outputCpu) + { + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + System.out.printf(","); + } + System.out.printf("\n\t\t\t\t{\n" + + "\t\t\t\t\t\"latency\": %1d,\n" + + "\t\t\t\t\t\"latency_ave\": %2$1.0f,\n" + + "\t\t\t\t\t\"latency_std\": %3$1.1f,\n" + + "\t\t\t\t\t\"latency_min\": %4$1d,\n" + + "\t\t\t\t\t\"latency_max\": %5$1d", + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + System.out.printf(",\n\t\t\t\t\t\"cpu\": %1$1.2f", + outputCpu); + } + System.out.printf("\n\t\t\t\t}"); + } + + @Override + public void print_latency_summary( + double latencyAve, + double latencyStd, + long latencyMin, + long latencyMax, + int[] latencyHistory, + long count, + double outputCpu) + { + if (_printIntervals) { + System.out.printf("\n\t\t\t],\n"); + } + System.out.printf("\t\t\t\"summary\":{\n" + + "\t\t\t\t\"latency_ave\": %1$1.1f,\n" + + "\t\t\t\t\"latency_std\": %2$1.1f,\n" + + "\t\t\t\t\"latency_min\": %3$1d,\n" + + "\t\t\t\t\"latency_max\": %4$1d,\n" + + "\t\t\t\t\"latency_50\": %5$1d,\n" + + "\t\t\t\t\"latency_90\": %6$1d,\n" + + "\t\t\t\t\"latency_99\": %7$1d,\n" + + "\t\t\t\t\"latency_99.99\": %8$1d,\n" + + "\t\t\t\t\"latency_99.9999\": %9$1d", + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[(int) (count * 50 / 100)], + latencyHistory[(int) (count * 90 / 100)], + latencyHistory[(int) (count * 99 / 100)], + latencyHistory[(int) (count * + (9999 / 10000))], + latencyHistory[(int) (count * + (999999 / 1000000))]); + if (_showCPU) { + System.out.printf(",\n\t\t\t\t\"cpu\": %1$1.1f", outputCpu); + } + System.out.printf("\n\t\t\t}\n\t\t}"); + } + + @Override + public void print_throughput_interval( + long lastMsgs, + long mps, + double mpsAve, + long bps, + double bpsAve, + long missingPackets, + double missingPacketsPercent, + double outputCpu) + { + if (_controlJsonIntervals) { + _controlJsonIntervals = false; + } else { + System.out.printf(","); + } + System.out.printf("\n\t\t\t\t{\n" + + "\t\t\t\t\t\"length\": %1d,\n" + + "\t\t\t\t\t\"packets\": %2d,\n" + + "\t\t\t\t\t\"packets/s\": %3d,\n" + + "\t\t\t\t\t\"packets/s_ave\": %4$1.2f,\n" + + "\t\t\t\t\t\"mbps\": %5$1.1f,\n" + + "\t\t\t\t\t\"mbps_ave\": %6$1.1f,\n" + + "\t\t\t\t\t\"lost\": %7$1d,\n" + + "\t\t\t\t\t\"lost_percent\": %8$1.2f", + _dataLength, + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(",\n\t\t\t\t\t\"cpu\": %1$1.2f", + outputCpu); + } + System.out.printf("\n\t\t\t\t}"); + } + + @Override + public void print_throughput_summary( + int length, + long intervalPacketsReceived, + long intervalTime, + long intervalBytesReceived, + long intervalMissingPackets, + double missingPacketsPercent, + double outputCpu) + { + if (_printIntervals) { + System.out.printf("\n\t\t\t],\n"); + } + System.out.printf("\t\t\t\"summary\":{\n" + + "\t\t\t\t\"packets\": %1$1d,\n" + + "\t\t\t\t\"packets/sAve\": %2$1.0f,\n" + + "\t\t\t\t\"mbpsAve\": %3$1.1f,\n" + + "\t\t\t\t\"lost\": %4$1d,\n" + + "\t\t\t\t\"lostPercent\": %5$1.2f", + intervalPacketsReceived, + intervalPacketsReceived * 1000000.0 + / intervalTime, + intervalBytesReceived * 1000000.0 + / intervalTime * 8.0 / 1000.0 / 1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(",\n\t\t\t\t\"cpu\": %1$1.2f", outputCpu); + } + System.out.printf("\n\t\t\t}\n\t\t}"); + } + public void print_initial_output() + { + System.out.printf("{\"perftest\":\n\t[\n\t\t{\n"); + } + public void print_final_output() + { + + System.out.printf("\n\t]\n}\n"); + + } +} diff --git a/srcJava/com/rti/perftest/harness/PerftestLegacyPrinter.java b/srcJava/com/rti/perftest/harness/PerftestLegacyPrinter.java new file mode 100644 index 00000000..3340872e --- /dev/null +++ b/srcJava/com/rti/perftest/harness/PerftestLegacyPrinter.java @@ -0,0 +1,147 @@ +package com.rti.perftest.harness; + + +public class PerftestLegacyPrinter extends PerftestPrinter { + + @Override + public void print_latency_header() + { + if(_printHeaders && _printIntervals) { + System.out.printf("\n\n********** New data length is %1d\n", + _dataLength); + System.out.flush(); + } + } + + @Override + public void print_throughput_header() + { + if(_printHeaders && _printIntervals) { + System.out.printf("\n\n********** New data length is %1d\n", + _dataLength); + System.out.flush(); + } + } + + @Override + public void print_latency_interval( + int latency, + double latencyAve, + double latencyStd, + int latencyMin, + int latencyMax, + double outputCpu) + { + System.out.printf("One way Latency: %1$6d " + + PERFT_TIME_UNIT + + " Ave %2$6.0f " + PERFT_TIME_UNIT + + " Std %3$6.1f " + PERFT_TIME_UNIT + + " Min %4$6d " + PERFT_TIME_UNIT + + " Max %5$6d " + PERFT_TIME_UNIT, + latency, + latencyAve, + latencyStd, + latencyMin, + latencyMax); + if (_showCPU) { + System.out.printf(" CPU %1$1.2f (%%)", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + + @Override + public void print_latency_summary( + double latencyAve, + double latencyStd, + long latencyMin, + long latencyMax, + int[] latencyHistory, + long count, + double outputCpu) + { + System.out.printf("Length: %1$5d" + + " Latency: Ave %2$6.0f " + PERFT_TIME_UNIT + + " Std %3$6.1f " + PERFT_TIME_UNIT + + " Min %4$6d " + PERFT_TIME_UNIT + + " Max %5$6d " + PERFT_TIME_UNIT + + " 50%% %6$6d " + PERFT_TIME_UNIT + + " 90%% %7$6d " + PERFT_TIME_UNIT + + " 99%% %8$6d " + PERFT_TIME_UNIT + + " 99.99%% %9$6d " + PERFT_TIME_UNIT + + " 99.9999%% %10$6d " + PERFT_TIME_UNIT, + _dataLength, + latencyAve, + latencyStd, + latencyMin, + latencyMax, + latencyHistory[(int) (count * 50 / 100)], + latencyHistory[(int) (count * 90 / 100)], + latencyHistory[(int) (count * 99 / 100)], + latencyHistory[(int) (count + * (9999 / 10000))], + latencyHistory[(int) (count + * (999999 / 1000000))]); + if (_showCPU) { + System.out.printf(" CPU %1$1.2f (%%)", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + + @Override + public void print_throughput_interval( + long lastMsgs, + long mps, + double mpsAve, + long bps, + double bpsAve, + long missingPackets, + double missingPacketsPercent, + double outputCpu) + { + System.out.printf("Packets: %1$8d Packets/s: %2$7d " + + "Packets/s(ave): %3$7.0f Mbps: %4$7.1f" + + " Mbps(ave): %5$7.1f Lost: %6$5d (%7$1.2f (%%))", + lastMsgs, + mps, + mpsAve, + bps * 8.0 / 1000.0 / 1000.0, + bpsAve * 8.0 / 1000.0 / 1000.0, + missingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(" CPU %1$1.2f (%%)", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } + + @Override + public void print_throughput_summary( + int length, + long intervalPacketsReceived, + long intervalTime, + long intervalBytesReceived, + long intervalMissingPackets, + double missingPacketsPercent, + double outputCpu) + { + System.out.printf("Length: %1$5d Packets: %2$8d " + + "Packets/s(ave): %3$7.0f " + + "Mbps(ave): %4$7.1f Lost: %5$5d (%6$1.2f%%)", + length, + intervalPacketsReceived, + intervalPacketsReceived * 1000000.0 / + intervalTime, + intervalBytesReceived * 1000000.0 / + intervalTime *8.0/1000.0/1000.0, + intervalMissingPackets, + missingPacketsPercent); + if (_showCPU) { + System.out.printf(" CPU %1$1.2f (%%)", outputCpu); + } + System.out.printf("\n"); + System.out.flush(); + } +} diff --git a/srcJava/com/rti/perftest/harness/PerftestPrinter.java b/srcJava/com/rti/perftest/harness/PerftestPrinter.java index e5e161b2..169388d5 100644 --- a/srcJava/com/rti/perftest/harness/PerftestPrinter.java +++ b/srcJava/com/rti/perftest/harness/PerftestPrinter.java @@ -1,486 +1,74 @@ package com.rti.perftest.harness; -enum PerftestOutputFormat +public abstract class PerftestPrinter { + public int _dataLength; + public boolean _printHeaders; + protected boolean _showCPU; + protected boolean _printIntervals; + protected boolean _printSummaryHeaders; + public final String PERFT_TIME_UNIT = "us"; + + public PerftestPrinter() + { + _dataLength = 100; + _printSummaryHeaders = true; + } + public void initialize( + boolean printIntervals, + boolean printHeaders, + boolean showCpu) + { + _printIntervals = printIntervals; + _printHeaders = printHeaders; + _showCPU = showCpu; + } + public void set_data_length(int dataLength) + { + _dataLength = dataLength; + } + public void set_header_printed(boolean printHeaders) { - LEGACY, - JSON, - CSV + _printHeaders = printHeaders; } + public abstract void print_latency_header(); + public abstract void print_throughput_header(); + public abstract void print_latency_interval( + int latency, + double latencyAve, + double latencyStd, + int latencyMin, + int latencyMax, + double outputCpu); + + public abstract void print_latency_summary( + double latencyAve, + double latencyStd, + long latencyMin, + long latencyMax, + int[] latencyHistory, + long count, + double outputCpu); + + public abstract void print_throughput_interval( + long lastMsgs, + long mps, + double mpsAve, + long bps, + double bpsAve, + long missingPackets, + double missingPacketsPercent, + double outputCpu); -public class PerftestPrinter { - private int _dataLength; - private boolean _printHeaders; - private boolean _showCPU; - private boolean _printIntervals; - private boolean _printSummaryHeaders; - private boolean _isJsonInitialized; - private boolean _controlJsonIntervals; - private PerftestOutputFormat _outputFormat; - public final String PERFT_TIME_UNIT = "us"; + public abstract void print_throughput_summary( + int length, + long intervalPacketsReceived, + long intervalTime, + long intervalBytesReceived, + long intervalMissingPackets, + double missingPacketsPercent, + double outputCpu); + + public void print_initial_output(){} - public PerftestPrinter() - { - _dataLength = 100; - _printSummaryHeaders = true; - _outputFormat = PerftestOutputFormat.CSV; - } - public void initialize( - boolean printIntervals, - String outputFormat, - boolean printHeaders, - boolean showCpu) - { - _printIntervals = printIntervals; - _printHeaders = printHeaders; - _showCPU = showCpu; - if (outputFormat.equals("csv")) { - _outputFormat = PerftestOutputFormat.CSV; - } else if (outputFormat.equals("json")) { - _outputFormat = PerftestOutputFormat.JSON; - _isJsonInitialized = false; - } else if (outputFormat.equals("legacy")) { - _outputFormat = PerftestOutputFormat.LEGACY; - } - } - public void set_data_length(int dataLength) - { - _dataLength = dataLength; - } - public void set_header_printed(boolean printHeaders) - { - _printHeaders = printHeaders; - } - public void print_latency_header() - { - switch (_outputFormat) { - case CSV: - if(_printHeaders && _printIntervals) { - System.out.printf("\nIntervals One-way Latency for %1d " + - "Bytes:\n", _dataLength); - System.out.printf("Length (Bytes)" + - ", Latency (" + PERFT_TIME_UNIT + - "), Ave (" + PERFT_TIME_UNIT + - "), Std (" + PERFT_TIME_UNIT + - "), Min (" + PERFT_TIME_UNIT + - "), Max (" + PERFT_TIME_UNIT + - ")"); - if (_showCPU) { - System.out.print(", CPU (%%)"); - } - } - System.out.print("\n"); - System.out.flush(); - break; - case JSON: - if (_isJsonInitialized) { - System.out.print(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; - } - System.out.printf("\t\t\t\"length\":%1d,\n", _dataLength); - if (_printIntervals) { - System.out.print("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - System.out.flush(); - break; - case LEGACY: - if(_printHeaders && _printIntervals) { - System.out.printf("\n\n********** New data length is %1d\n", - _dataLength); - System.out.flush(); - } - break; - } - } - public void print_throughput_header() - { - switch (_outputFormat) { - case CSV: - if(_printHeaders && _printIntervals) { - System.out.printf("\nIntervals Throughput for %1d " + - "Bytes:\n", _dataLength); - System.out.printf("Length (Bytes), Total Samples, " + - "Samples/s, Ave Samples/s, " + - "Mbps, Ave Mbps" + - ", Lost Samples, Lost Samples (%%)"); - if (_showCPU) { - System.out.printf(", CPU (%%)"); - } - } - System.out.printf("\n"); - System.out.flush(); - break; - case JSON: - if (_isJsonInitialized) { - System.out.printf(",\n\t\t{\n"); - } else { - _isJsonInitialized = true; - } - System.out.printf("\t\t\t\"length\":%1d,\n", _dataLength); - if (_printIntervals) { - System.out.printf("\t\t\t\"intervals\":[\n"); - _controlJsonIntervals = true; - } - System.out.flush(); - break; - case LEGACY: - if(_printHeaders && _printIntervals) { - System.out.printf("\n\n********** New data length is %1d\n", - _dataLength); - System.out.flush(); - } - break; - } - } - public void print_latency_interval( - int latency, - double latencyAve, - double latencyStd, - int latencyMin, - int latencyMax, - double outputCpu) - { - switch (_outputFormat) { - case CSV: - System.out.printf("%1$14d,%2$13d,%3$9.0f,%4$9.1f,%5$9d" + - ",%6$9d", - _dataLength, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - System.out.printf(",%1$8.2f", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - case JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - System.out.printf(","); - } - System.out.printf("\n\t\t\t\t{\n" + - "\t\t\t\t\t\"latency\": %1d,\n" + - "\t\t\t\t\t\"latency_ave\": %2$1.0f,\n" + - "\t\t\t\t\t\"latency_std\": %3$1.1f,\n" + - "\t\t\t\t\t\"latency_min\": %4$1d,\n" + - "\t\t\t\t\t\"latency_max\": %5$1d", - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - System.out.printf(",\n\t\t\t\t\t\"cpu\": %1$1.2f", - outputCpu); - } - System.out.printf("\n\t\t\t\t}"); - break; - case LEGACY: - System.out.printf("One way Latency: %1$6d " - + PERFT_TIME_UNIT + - " Ave %2$6.0f " + PERFT_TIME_UNIT + - " Std %3$6.1f " + PERFT_TIME_UNIT + - " Min %4$6d " + PERFT_TIME_UNIT + - " Max %5$6d " + PERFT_TIME_UNIT, - latency, - latencyAve, - latencyStd, - latencyMin, - latencyMax); - if (_showCPU) { - System.out.printf(" CPU %1$1.2f (%%)", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - } - } - public void print_latency_summary( - double latencyAve, - double latencyStd, - long latencyMin, - long latencyMax, - int[] latencyHistory, - long count, - double outputCpu) - { - switch (_outputFormat) { - case CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - System.out.printf("\nOne-way Latency Summary:\n"); - System.out.printf("Length (Bytes)" + - ", Ave (" + PERFT_TIME_UNIT + - "), Std (" + PERFT_TIME_UNIT + - "), Min (" + PERFT_TIME_UNIT + - "), Max (" + PERFT_TIME_UNIT + - "), 50%% (" + PERFT_TIME_UNIT + - "), 90%% (" + PERFT_TIME_UNIT + - "), 99%% (" + PERFT_TIME_UNIT + - "), 99.99%% (" + PERFT_TIME_UNIT + - "), 99.9999%% (" +PERFT_TIME_UNIT + - ")"); - if (_showCPU) { - System.out.printf(", CPU (%%)"); - } - System.out.printf("\n"); - } - System.out.printf("%1$14d,%2$9.0f,%3$9.1f,%4$9d,%5$9d," + - "%6$9d,%7$9d,%8$9d,%9$12d,%10$14d", - _dataLength, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[(int) (count * 50 / 100)], - latencyHistory[(int) (count * 90 / 100)], - latencyHistory[(int) (count * 99 / 100)], - latencyHistory[(int) (count * - (9999 / 10000))], - latencyHistory[(int) (count * - (999999 / 1000000))]); - if (_showCPU) { - System.out.printf(",%1$8.2f", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - case JSON: - if (_printIntervals) { - System.out.printf("\n\t\t\t],\n"); - } - System.out.printf("\t\t\t\"summary\":{\n" + - "\t\t\t\t\"latency_ave\": %1$1.1f,\n" + - "\t\t\t\t\"latency_std\": %2$1.1f,\n" + - "\t\t\t\t\"latency_min\": %3$1d,\n" + - "\t\t\t\t\"latency_max\": %4$1d,\n" + - "\t\t\t\t\"latency_50\": %5$1d,\n" + - "\t\t\t\t\"latency_90\": %6$1d,\n" + - "\t\t\t\t\"latency_99\": %7$1d,\n" + - "\t\t\t\t\"latency_99.99\": %8$1d,\n" + - "\t\t\t\t\"latency_99.9999\": %9$1d", - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[(int) (count * 50 / 100)], - latencyHistory[(int) (count * 90 / 100)], - latencyHistory[(int) (count * 99 / 100)], - latencyHistory[(int) (count * - (9999 / 10000))], - latencyHistory[(int) (count * - (999999 / 1000000))]); - if (_showCPU) { - System.out.printf(",\n\t\t\t\t\"cpu\": %1$1.1f", outputCpu); - } - System.out.printf("\n\t\t\t}\n\t\t}"); - break; - case LEGACY: - System.out.printf("Length: %1$5d" + - " Latency: Ave %2$6.0f " + PERFT_TIME_UNIT + - " Std %3$6.1f " + PERFT_TIME_UNIT + - " Min %4$6d " + PERFT_TIME_UNIT + - " Max %5$6d " + PERFT_TIME_UNIT + - " 50%% %6$6d " + PERFT_TIME_UNIT + - " 90%% %7$6d " + PERFT_TIME_UNIT + - " 99%% %8$6d " + PERFT_TIME_UNIT + - " 99.99%% %9$6d " + PERFT_TIME_UNIT + - " 99.9999%% %10$6d " + PERFT_TIME_UNIT, - _dataLength, - latencyAve, - latencyStd, - latencyMin, - latencyMax, - latencyHistory[(int) (count * 50 / 100)], - latencyHistory[(int) (count * 90 / 100)], - latencyHistory[(int) (count * 99 / 100)], - latencyHistory[(int) (count - * (9999 / 10000))], - latencyHistory[(int) (count - * (999999 / 1000000))]); - if (_showCPU) { - System.out.printf(" CPU %1$1.2f (%%)", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - } - } - public void print_throughput_interval( - long lastMsgs, - long mps, - double mpsAve, - long bps, - double bpsAve, - long missingPackets, - double missingPacketsPercent, - double outputCpu) - { - switch (_outputFormat) { - case CSV: - System.out.printf("%1$14d,%2$14d,%3$11d,%4$14.0f,%5$9.1f"+ - ",%6$10.1f,%7$13d,%8$17.2f", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(",%1$8.2f", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - case JSON: - if (_controlJsonIntervals) { - _controlJsonIntervals = false; - } else { - System.out.printf(","); - } - System.out.printf("\n\t\t\t\t{\n" + - "\t\t\t\t\t\"length\": %1d,\n" + - "\t\t\t\t\t\"packets\": %2d,\n" + - "\t\t\t\t\t\"packets/s\": %3d,\n" + - "\t\t\t\t\t\"packets/s_ave\": %4$1.2f,\n" + - "\t\t\t\t\t\"mbps\": %5$1.1f,\n" + - "\t\t\t\t\t\"mbps_ave\": %6$1.1f,\n" + - "\t\t\t\t\t\"lost\": %7$1d,\n" + - "\t\t\t\t\t\"lost_percent\": %8$1.2f", - _dataLength, - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(",\n\t\t\t\t\t\"cpu\": %1$1.2f", - outputCpu); - } - System.out.printf("\n\t\t\t\t}"); - break; - case LEGACY: - System.out.printf("Packets: %1$8d Packets/s: %2$7d " + - "Packets/s(ave): %3$7.0f Mbps: %4$7.1f" + - " Mbps(ave): %5$7.1f Lost: %6$5d (%7$1.2f (%%))", - lastMsgs, - mps, - mpsAve, - bps * 8.0 / 1000.0 / 1000.0, - bpsAve * 8.0 / 1000.0 / 1000.0, - missingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(" CPU %1$1.2f (%%)", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - } - } - public void print_throughput_summary( - int length, - long intervalPacketsReceived, - long intervalTime, - long intervalBytesReceived, - long intervalMissingPackets, - double missingPacketsPercent, - double outputCpu) - { - switch (_outputFormat) { - case CSV: - if (_printSummaryHeaders && _printHeaders) { - if (!_printIntervals && _printSummaryHeaders) { - _printSummaryHeaders = _printIntervals; - } - System.out.printf("\nThroughput Summary:\n"); - System.out.printf("Length (Bytes), Total Samples," + - " Ave Samples/s, Ave Mbps, " + - "Lost Samples, Lost Samples (%%)"); - if (_showCPU) { - System.out.printf(", CPU (%%)"); - } - System.out.printf("\n"); - } - System.out.printf("%1$14d,%2$14d,%3$14.0f,%4$12.1f," + - "%5$13d,%6$17.2f", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000.0 - / intervalTime, - intervalBytesReceived * 1000000.0 - / intervalTime * 8.0 / 1000.0 / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(",%1$8.2f", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - case JSON: - if (_printIntervals) { - System.out.printf("\n\t\t\t],\n"); - } - System.out.printf("\t\t\t\"summary\":{\n" + - "\t\t\t\t\"packets\": %1$1d,\n" + - "\t\t\t\t\"packets/sAve\": %2$1.0f,\n" + - "\t\t\t\t\"mbpsAve\": %3$1.1f,\n" + - "\t\t\t\t\"lost\": %4$1d,\n" + - "\t\t\t\t\"lostPercent\": %5$1.2f", - intervalPacketsReceived, - intervalPacketsReceived * 1000000.0 - / intervalTime, - intervalBytesReceived * 1000000.0 - / intervalTime * 8.0 / 1000.0 / 1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(",\n\t\t\t\t\"cpu\": %1$1.2f", outputCpu); - } - System.out.printf("\n\t\t\t}\n\t\t}"); - break; - case LEGACY: - System.out.printf("Length: %1$5d Packets: %2$8d " + - "Packets/s(ave): %3$7.0f " + - "Mbps(ave): %4$7.1f Lost: %5$5d (%6$1.2f%%)", - length, - intervalPacketsReceived, - intervalPacketsReceived * 1000000.0 / - intervalTime, - intervalBytesReceived * 1000000.0 / - intervalTime *8.0/1000.0/1000.0, - intervalMissingPackets, - missingPacketsPercent); - if (_showCPU) { - System.out.printf(" CPU %1$1.2f (%%)", outputCpu); - } - System.out.printf("\n"); - System.out.flush(); - break; - } - } - public void print_initial_output() - { - if (_outputFormat.equals(PerftestOutputFormat.JSON)) { - System.out.printf("{\"perftest\":\n\t[\n\t\t{\n"); - } - } - public void print_final_output() - { - if (_outputFormat.equals(PerftestOutputFormat.JSON)) { - System.out.printf("\n\t]\n}\n"); - } - } + public void print_final_output(){} } diff --git a/srcJava/com/rti/perftest/harness/ThroughputListener.java b/srcJava/com/rti/perftest/harness/ThroughputListener.java index 2fa1185b..3911ed8e 100644 --- a/srcJava/com/rti/perftest/harness/ThroughputListener.java +++ b/srcJava/com/rti/perftest/harness/ThroughputListener.java @@ -170,8 +170,8 @@ public void processMessage(TestMessage message) { } _beginTime = PerfTest.getTimeUsec(); - PerfTest._printer.set_data_length(message.size + - PerfTest.OVERHEAD_BYTES); + PerfTest._printer._dataLength = message.size + + PerfTest.OVERHEAD_BYTES; PerfTest._printer.print_throughput_header(); } @@ -232,7 +232,7 @@ public void print_summary_throughput(TestMessage message, boolean endTest) { + intervalMissingPackets); } - double outputCpu = 0; + double outputCpu = 0.0; if (PerfTest._showCpu) { outputCpu = CpuMonitor.get_cpu_average(); }