Repository navigation
Expand file tree
/
Copy pathTestRepository.h
More file actions
53 lines (38 loc) · 1.61 KB
/
Copy pathTestRepository.h
File metadata and controls
53 lines (38 loc) · 1.61 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
#pragma once
#include <map>
#include <memory>
#include <string>
#include "Disruptor/TypeInfo.h"
#include "Disruptor.PerfTests/TestFactory.h"
namespace Disruptor
{
namespace PerfTests
{
class TestRepository
{
public:
static const TestRepository& instance();
std::vector< ThroughputTestInfo > allThrougputTests() const;
bool tryGetThroughputTest(const std::string& testName, ThroughputTestInfo& testInfo) const;
std::vector< LatencyTestInfo > allLatencyTests() const;
bool tryGetLatencyTest(const std::string& testName, LatencyTestInfo& testInfo) const;
private:
TestRepository();
template <class TTest>
void registerTest()
{
static_assert(std::is_base_of< IThroughputTest, TTest >::value || std::is_base_of< ILatencyTest, TTest >::value,
"TTest should implement IThroughputTest or ILatencyTest");
std::function<std::shared_ptr<TTest>()>&& factory = []() -> std::shared_ptr<TTest>
{
return std::make_shared<TTest>();
};
registerTest(Utils::getMetaTypeInfo< TTest >(), factory);
}
void registerTest(const TypeInfo& typeInfo, const std::function<std::shared_ptr< IThroughputTest >()>& testFactory);
void registerTest(const TypeInfo& typeInfo, const std::function<std::shared_ptr< ILatencyTest >()>& testFactory);
std::map< std::string, ThroughputTestInfo > m_throughputTestInfosByName;
std::map< std::string, LatencyTestInfo > m_latencyTestInfosByName;
};
} // namespace PerfTests
} // namespace Disruptor