-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathBenchmarks.cpp
36 lines (32 loc) · 1.21 KB
/
Benchmarks.cpp
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
#include "PluginEditor.h"
#include "catch2/benchmark/catch_benchmark_all.hpp"
#include "catch2/catch_test_macros.hpp"
TEST_CASE ("Boot performance")
{
BENCHMARK_ADVANCED ("Processor constructor")
(Catch::Benchmark::Chronometer meter)
{
std::vector<Catch::Benchmark::storage_for<PluginProcessor>> storage (size_t (meter.runs()));
meter.measure ([&] (int i) { storage[(size_t) i].construct(); });
};
BENCHMARK_ADVANCED ("Processor destructor")
(Catch::Benchmark::Chronometer meter)
{
std::vector<Catch::Benchmark::destructable_object<PluginProcessor>> storage (size_t (meter.runs()));
for (auto& s : storage)
s.construct();
meter.measure ([&] (int i) { storage[(size_t) i].destruct(); });
};
BENCHMARK_ADVANCED ("Editor open and close")
(Catch::Benchmark::Chronometer meter)
{
PluginProcessor plugin;
// due to complex construction logic of the editor, let's measure open/close together
meter.measure ([&] (int /* i */) {
auto editor = plugin.createEditorIfNeeded();
plugin.editorBeingDeleted (editor);
delete editor;
return plugin.getActiveEditor();
});
};
}