1 // Copyright 2022 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 #pragma once 15 16 #include <cstdint> 17 18 namespace pw::perf_test { 19 20 // The data that will be reported on completion of an iteration. 21 struct IterationResult { 22 int64_t number; 23 int64_t result; 24 }; 25 26 // The data that will be reported upon the completion of an iteration. 27 struct Results { 28 int64_t mean; 29 int64_t max; 30 int64_t min; 31 int iterations; 32 }; 33 34 // Stores information on the upcoming collection of tests. 35 struct TestRunInfo { 36 int total_tests; 37 int default_iterations; 38 }; 39 40 struct TestCase { 41 const char* name; 42 }; 43 44 // This is a declaration of the base EventHandler class. An EventHandler 45 // collects and reports test results. Both the state and the framework classes 46 // use their functions to report what happens at each stage 47 class EventHandler { 48 public: 49 virtual ~EventHandler() = default; 50 51 // Called before all tests are run 52 virtual void RunAllTestsStart(const TestRunInfo& summary) = 0; 53 54 // Called after all tests are run 55 virtual void RunAllTestsEnd() = 0; 56 57 // Called when a new performance test is started 58 virtual void TestCaseStart(const TestCase& info) = 0; 59 60 // Called to output the results of an iteration 61 virtual void TestCaseIteration(const IterationResult& result) = 0; 62 63 // Called after a performance test ends 64 virtual void TestCaseEnd(const TestCase& info, const Results& end_result) = 0; 65 }; 66 67 } // namespace pw::perf_test 68