OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
BenchmarkData Struct Reference

Classes

struct  Overhead
struct  ReceiveMarks
struct  SendMarks
struct  SquareVariance

Public Types

typedef std::vector< PerformanceCounter::SpanLatencies

Static Public Member Functions

static PerformanceCounter::Span oneWaySpanNano (const SendMarks &sm, const ReceiveMarks &rm)
static double stdDev (const Latencies &data)
static void processAndReportLatencies (const std::string &name, Latencies &latencies)
static void reportResults (const std::string &name, const SendMarks *sendMarksArray, const ReceiveMarks *receiveMarksArray, std::size_t count, const Overhead &overhead)

Detailed Description

Definition at line 37 of file BenchmarkData.h.

Member Typedef Documentation

◆ Latencies

typedef std::vector<PerformanceCounter::Span> Latencies

Definition at line 87 of file BenchmarkData.h.

Member Function Documentation

◆ oneWaySpanNano()

PerformanceCounter::Span oneWaySpanNano ( const SendMarks & sm,
const ReceiveMarks & rm )
inlinestatic

Definition at line 82 of file BenchmarkData.h.

83 {
84 return PerformanceCounter::nsSpan(rm.recvFinish, sm.sendStart);
85 }
static Span nsSpan(const PerformanceCounter::Count &stop, const PerformanceCounter::Count &start)

◆ processAndReportLatencies()

void processAndReportLatencies ( const std::string & name,
Latencies & latencies )
inlinestatic

Definition at line 114 of file BenchmarkData.h.

115 {
116 sort(latencies.begin(), latencies.end());
117
118 const std::size_t NameWidth = 23;
119
120 std::clog << std::setw(NameWidth) << std::left << name;
121
122 if(name.length() > NameWidth)
123 std::clog << std::endl << std::setw(NameWidth) << ' ';
124
125 std::clog
126 << std::right
127 << "min: " << std::setw(7) << *latencies.begin()
128 << " median: " << std::setw(7) << latencies.at(latencies.size() / 2)
129 << " 99th percentile: " << std::setw(6)
130 << latencies.at(static_cast<std::size_t>(std::ceil((latencies.size() * 99) / 100.0)) - 1)
131 << " stdDev: " << std::setw(10) << std::fixed << std::setprecision(2) << stdDev(latencies)
132 << std::endl;
133 }
static double stdDev(const Latencies &data)

◆ reportResults()

void reportResults ( const std::string & name,
const SendMarks * sendMarksArray,
const ReceiveMarks * receiveMarksArray,
std::size_t count,
const Overhead & overhead )
inlinestatic

Definition at line 135 of file BenchmarkData.h.

138 {
139 const std::string baseName = name + '_';
140
141 std::ofstream receiveStream(std::string(baseName + "recv.csv").c_str(), std::ios_base::ate);
142 std::ofstream sendStream(std::string(baseName + "send.csv").c_str(), std::ios_base::ate);
143 std::ofstream overallSendStream(std::string(baseName + "overallsend.csv").c_str(), std::ios_base::ate);
144 std::ofstream sendAndReceiveStream(std::string(baseName + "sendrecv.csv").c_str(), std::ios_base::ate);
145
146#define MEASURE_NETWORK_LATENCY 1 // Includes the network-related latency and CME's or emulator processing time.
147
148#if MEASURE_NETWORK_LATENCY
149 std::ofstream oneWayStream(std::string(baseName + "oneway.csv").c_str(), std::ios_base::ate);
150 Latencies oneWayLatencies;
151#endif
152
153 Latencies sendLatencies, overallSendLatencies, receiveLatencies, sendAndReceiveLatencies;
154
155 for(std::size_t i = 0; i < count; ++i)
156 {
157 const SendMarks & sendMarks = sendMarksArray[i];
158 const ReceiveMarks & receiveMarks = receiveMarksArray[i];
159
160 assert(!PerformanceCounter::isUndefinedValue(receiveMarks.recvStart));
161
162 receiveLatencies.push_back(receiveMarks.recvSpanNano() - overhead.receive);
163 receiveStream << *receiveLatencies.rbegin() << std::endl;
164
165 sendLatencies.push_back(sendMarks.sendSpanNano() - overhead.send);
166 sendStream << *sendLatencies.rbegin() << std::endl;
167
168 overallSendLatencies.push_back(sendMarks.overallSendSpanNano() - overhead.overallSend);
169 overallSendStream << *overallSendLatencies.rbegin() << std::endl;
170
171 const PerformanceCounter::Span sendAndReceiveLatency = *sendLatencies.rbegin() + *receiveLatencies.rbegin();
172 sendAndReceiveLatencies.push_back(sendAndReceiveLatency);
173 sendAndReceiveStream << *sendAndReceiveLatencies.rbegin() << std::endl;
174
175#if MEASURE_NETWORK_LATENCY
176 oneWayLatencies.push_back((oneWaySpanNano(sendMarks, receiveMarks) - overhead.oneWay) / 2);
177 oneWayStream << *oneWayLatencies.rbegin() << std::endl;
178#endif
179 }
180
181 std::clog << std::endl << name << " (nanoseconds): \n" << std::endl;
182
183 processAndReportLatencies("Handler Receive", receiveLatencies);
184 processAndReportLatencies("Handler Send", sendLatencies);
185 processAndReportLatencies("Handler Send+Receive", sendAndReceiveLatencies);
187 "OS + Handler Send (depends on the network card, kernel bypass software, OS load)",
188 overallSendLatencies
189 );
190
191#if MEASURE_NETWORK_LATENCY
192 processAndReportLatencies("One-Way (Round-Trip/2)", oneWayLatencies);
193#endif
194
195#define REPORT_OVERHEAD 1
196
197#if REPORT_OVERHEAD
198 std::clog
199 << std::endl << "Measurement overhead:" << std::endl
200 << "Send: " << overhead.send << std::endl
201 << "Receive: " << overhead.receive << std::endl
202 << "Send+Receive: " << overhead.send + overhead.receive << std::endl
203 << "OS + Handler Send: " << overhead.overallSend << std::endl;
204#endif
205
206#if MEASURE_NETWORK_LATENCY
207 std::clog << "One way:" << overhead.oneWay << std::endl;
208#endif
209 }
static bool isUndefinedValue(const Count &value)
std::vector< PerformanceCounter::Span > Latencies
static void processAndReportLatencies(const std::string &name, Latencies &latencies)
static PerformanceCounter::Span oneWaySpanNano(const SendMarks &sm, const ReceiveMarks &rm)

◆ stdDev()

double stdDev ( const Latencies & data)
inlinestatic

Definition at line 103 of file BenchmarkData.h.

104 {
105 const std::size_t size = data.size();
106 assert(size > 1);
107
108 const double mean = std::accumulate(data.begin(), data.end(), static_cast<double>(0.0f)) / size;
109
110 return std::sqrt(
111 std::accumulate(data.begin(), data.end(), static_cast<double>(0.0f), SquareVariance(mean)) / (size - 1));
112 }
constexpr std::enable_if<!details::HasMemberTraits< Value >::value, size_t >::type size() noexcept
Definition Memory.h:303