blob: 4ec5bf164893af324ea64fb0c8e05728316768e2 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#include "map/benchmark_provider.hpp"
#include "geometry/rect2d.hpp"
#include "base/timer.hpp"
#include "base/thread.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
#include "std/shared_ptr.hpp"
class Framework;
/// BenchmarkEngine is class which:
/// - Creates it's own thread
/// - Feeds the Framework with the paint tasks he wants to performs
/// - Wait until each tasks completion
/// - Measure the time of each task and save the result
class BenchmarkEngine
{
threads::Thread m_thread;
double m_paintDuration;
double m_maxDuration;
m2::RectD m_maxDurationRect;
m2::RectD m_curBenchmarkRect;
string m_startTime;
struct BenchmarkResult
{
string m_name;
m2::RectD m_rect;
double m_time;
};
vector<BenchmarkResult> m_benchmarkResults;
my::Timer m_benchmarksTimer;
struct Benchmark
{
shared_ptr<BenchmarkRectProvider> m_provider;
string m_name;
};
class Routine : public threads::IRoutine
{
public:
Routine(BenchmarkEngine & engine);
// threads::IRoutine overrides:
void Do() override;
private:
BenchmarkEngine & m_engine;
};
vector<Benchmark> m_benchmarks;
size_t m_curBenchmark;
Framework * m_framework;
void BenchmarkCommandFinished();
bool NextBenchmarkCommand();
void SaveBenchmarkResults();
void SendBenchmarkResults();
void MarkBenchmarkResultsStart();
void MarkBenchmarkResultsEnd();
void PrepareMaps();
friend class DoGetBenchmarks;
public:
BenchmarkEngine(Framework * fw);
void Start();
};
|