~mardy/unity-scopes-api/clientid-1554040

« back to all changes in this revision

Viewing changes to include/unity/scopes/testing/OutOfProcessBenchmark.h

  • Committer: CI bot
  • Author(s): Tarmac
  • Date: 2014-03-12 16:58:32 UTC
  • mfrom: (163.45.63 devel)
  • Revision ID: ps-jenkins@lists.canonical.com-20140312165832-ngmnoud825y533pk
Sync with devel branch - updated scopes API to 0.4.0. See RELEASE_NOTES for list of all changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical Ltd
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef UNITY_SCOPES_TESTING_OUT_OF_PROCESS_BENCHMARK_H
 
20
#define UNITY_SCOPES_TESTING_OUT_OF_PROCESS_BENCHMARK_H
 
21
 
 
22
#include <unity/scopes/testing/InProcessBenchmark.h>
 
23
 
 
24
namespace unity
 
25
{
 
26
 
 
27
namespace scopes
 
28
{
 
29
class ScopeBase;
 
30
 
 
31
namespace testing
 
32
{
 
33
 
 
34
/**
 
35
 * \brief The OutOfProcessBenchmark class provides scope authors
 
36
 * with runtime benchmarking capabilities. The actual runs are executed in another process.
 
37
 *
 
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.
 
42
 *
 
43
 * \code
 
44
 * unity::scopes::testing::OutOfProcessBenchmark benchmark;
 
45
 *
 
46
 * unity::scopes::Query query{scope_id};
 
47
 * query.set_query_string(scope_query_string);
 
48
 *
 
49
 * unity::scopes::SearchMetadata meta_data{default_locale, default_form_factor};
 
50
 *
 
51
 * unity::scopes::testing::Benchmark::QueryConfiguration config;
 
52
 * config.sampler = [query, meta_data]()
 
53
 * {
 
54
 *     return std::make_pair(query, meta_data);
 
55
 * };
 
56
 *
 
57
 * auto result = benchmark.for_query(scope, config);
 
58
 * \endcode
 
59
 *
 
60
 */
 
61
class OutOfProcessBenchmark : public InProcessBenchmark
 
62
{
 
63
public:
 
64
    OutOfProcessBenchmark() = default;
 
65
 
 
66
    Result for_query(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
 
67
                     QueryConfiguration configuration) override;
 
68
 
 
69
    Result for_preview(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
 
70
                       PreviewConfiguration preview_configuration) override;
 
71
 
 
72
    Result for_activation(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
 
73
                          ActivationConfiguration activation_configuration) override;
 
74
 
 
75
    Result for_action(const std::shared_ptr<unity::scopes::ScopeBase>& scope,
 
76
                      ActionConfiguration activation_configuration) override;
 
77
};
 
78
 
 
79
} // namespace testing
 
80
 
 
81
} // namespace scopes
 
82
 
 
83
} // namespace unity
 
84
 
 
85
#endif