John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef TESTS_BENCHMARK_H |
| 17 | #define TESTS_BENCHMARK_H |
| 18 | |
Chris Craik | 8160f20 | 2015-12-02 14:50:25 -0800 | [diff] [blame^] | 19 | #include "tests/common/TestScene.h" |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 20 | |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | #include <vector> |
| 23 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
| 27 | struct BenchmarkOptions { |
| 28 | int count; |
| 29 | }; |
| 30 | |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 31 | typedef test::TestScene* (*CreateScene)(const BenchmarkOptions&); |
| 32 | |
| 33 | template <class T> |
| 34 | test::TestScene* simpleCreateScene(const BenchmarkOptions&) { |
| 35 | return new T(); |
| 36 | } |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 37 | |
| 38 | struct BenchmarkInfo { |
| 39 | std::string name; |
| 40 | std::string description; |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 41 | CreateScene createScene; |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | class Benchmark { |
| 45 | public: |
| 46 | Benchmark(const BenchmarkInfo& info) { |
| 47 | registerBenchmark(info); |
| 48 | } |
| 49 | |
| 50 | private: |
| 51 | Benchmark() = delete; |
| 52 | Benchmark(const Benchmark&) = delete; |
| 53 | Benchmark& operator=(const Benchmark&) = delete; |
| 54 | |
| 55 | static void registerBenchmark(const BenchmarkInfo& info); |
| 56 | }; |
| 57 | |
| 58 | } /* namespace uirenderer */ |
| 59 | } /* namespace android */ |
| 60 | |
| 61 | #endif /* TESTS_BENCHMARK_H */ |