2
* Copyright (C) 2013 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
19
#ifndef UNITY_SCOPES_TESTING_OUT_OF_PROCESS_BENCHMARK_H
20
#define UNITY_SCOPES_TESTING_OUT_OF_PROCESS_BENCHMARK_H
22
#include <unity/scopes/testing/InProcessBenchmark.h>
35
* \brief The OutOfProcessBenchmark class provides scope authors
36
* with runtime benchmarking capabilities. The actual runs are executed in another process.
38
* Please note that this class provides better test isolation than the class InProcessBenchmark
39
* and we promote use of this implementation due to this feature. However, as the internal
40
* implementation relies on fork(), the results in case of multi-threaded environments that exist
41
* before the execution of the benchmark are undefined.
44
* unity::scopes::testing::OutOfProcessBenchmark benchmark;
46
* unity::scopes::Query query{scope_id};
47
* query.set_query_string(scope_query_string);
49
* unity::scopes::SearchMetadata meta_data{default_locale, default_form_factor};
51
* unity::scopes::testing::Benchmark::QueryConfiguration config;
52
* config.sampler = [query, meta_data]()
54
* return std::make_pair(query, meta_data);
57
* auto result = benchmark.for_query(scope, config);
61
class OutOfProcessBenchmark : public InProcessBenchmark
64
OutOfProcessBenchmark() = default;
66
Result for_query(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
67
QueryConfiguration configuration) override;
69
Result for_preview(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
70
PreviewConfiguration preview_configuration) override;
72
Result for_activation(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
73
ActivationConfiguration activation_configuration) override;
75
Result for_action(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
76
ActionConfiguration activation_configuration) override;
79
} // namespace testing