blob: 1454c0f875458c16da688ed6b210c879a2599ee7 [file] [log] [blame]
Moritz Pflanzera4f711b2017-07-05 11:02:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef ARM_COMPUTE_TEST_PROFILER
25#define ARM_COMPUTE_TEST_PROFILER
26
27#include "instruments/Instrument.h"
28
29#include <map>
30#include <memory>
31#include <string>
32#include <vector>
33
34namespace arm_compute
35{
36namespace test
37{
38namespace framework
39{
40/** Profiler class to collect benchmark numbers.
41 *
42 * A profiler manages multiple instruments that can collect different types of benchmarking numbers.
43 */
44class Profiler
45{
46public:
47 /** Mapping from instrument ids to their measurements. */
48 using MeasurementsMap = std::map<std::string, std::vector<Instrument::Measurement>>;
49
50 /** Add @p instrument to the performance monitor.
51 *
52 * All added instruments will be used when @ref start or @ref stop are
53 * called to make measurements.
54 *
55 * @param[in] instrument Instrument to be used to measure performance.
56 */
57 void add(std::unique_ptr<Instrument> instrument);
58
59 /** Start all added instruments to measure performance. */
60 void start();
61
62 /** Stop all added instruments. */
63 void stop();
64
65 /** Return measurements for all instruments. */
66 const MeasurementsMap &measurements() const;
67
68private:
69 std::vector<std::unique_ptr<Instrument>> _instruments{};
70 MeasurementsMap _measurements{};
71};
72} // namespace framework
73} // namespace test
74} // namespace arm_compute
75#endif /* ARM_COMPUTE_TEST_PROFILER */