Repository navigation
Expand file tree
/
Copy pathPerfTestUtil.cpp
More file actions
60 lines (49 loc) · 1.47 KB
/
Copy pathPerfTestUtil.cpp
File metadata and controls
60 lines (49 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "stdafx.h"
#include "PerfTestUtil.h"
#include <boost/date_time.hpp>
#include "Disruptor/IEventProcessor.h"
#include "Disruptor/ISequence.h"
namespace Disruptor
{
namespace PerfTests
{
namespace PerfTestUtil
{
std::int64_t accumulatedAddition(std::int64_t iterations)
{
std::int64_t temp = 0L;
for (std::int64_t i = 0L; i < iterations; i++)
{
temp += i;
}
return temp;
}
void failIf(std::int64_t a, std::int64_t b, const std::string& message)
{
if (a == b)
{
throw std::runtime_error(message.empty() ? "Test failed " + std::to_string(a) + " == " + std::to_string(b) : message);
}
}
void failIfNot(std::int64_t a, std::int64_t b, const std::string& message)
{
if (a != b)
{
throw std::runtime_error(message.empty() ? "Test failed " + std::to_string(a) + " != " + std::to_string(b) : message);
}
}
void waitForEventProcessorSequence(std::int64_t expectedCount, const std::shared_ptr< IEventProcessor >& batchEventProcessor)
{
while (batchEventProcessor->sequence()->value() != expectedCount)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
std::string utcDateToString()
{
auto t(boost::posix_time::second_clock::universal_time());
return to_simple_string(t);
}
} // namespace PerfTestUtil
} // namespace PerfTests
} // namespace Disruptor