xref: /aosp_15_r20/external/libcxx/utils/google-benchmark/src/complexity.h (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker // Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
2*58b9f456SAndroid Build Coastguard Worker //
3*58b9f456SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*58b9f456SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*58b9f456SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*58b9f456SAndroid Build Coastguard Worker //
7*58b9f456SAndroid Build Coastguard Worker //     http://www.apache.org/licenses/LICENSE-2.0
8*58b9f456SAndroid Build Coastguard Worker //
9*58b9f456SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*58b9f456SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*58b9f456SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*58b9f456SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*58b9f456SAndroid Build Coastguard Worker // limitations under the License.
14*58b9f456SAndroid Build Coastguard Worker 
15*58b9f456SAndroid Build Coastguard Worker // Source project : https://github.com/ismaelJimenez/cpp.leastsq
16*58b9f456SAndroid Build Coastguard Worker // Adapted to be used with google benchmark
17*58b9f456SAndroid Build Coastguard Worker 
18*58b9f456SAndroid Build Coastguard Worker #ifndef COMPLEXITY_H_
19*58b9f456SAndroid Build Coastguard Worker #define COMPLEXITY_H_
20*58b9f456SAndroid Build Coastguard Worker 
21*58b9f456SAndroid Build Coastguard Worker #include <string>
22*58b9f456SAndroid Build Coastguard Worker #include <vector>
23*58b9f456SAndroid Build Coastguard Worker 
24*58b9f456SAndroid Build Coastguard Worker #include "benchmark/benchmark.h"
25*58b9f456SAndroid Build Coastguard Worker 
26*58b9f456SAndroid Build Coastguard Worker namespace benchmark {
27*58b9f456SAndroid Build Coastguard Worker 
28*58b9f456SAndroid Build Coastguard Worker // Return a vector containing the bigO and RMS information for the specified
29*58b9f456SAndroid Build Coastguard Worker // list of reports. If 'reports.size() < 2' an empty vector is returned.
30*58b9f456SAndroid Build Coastguard Worker std::vector<BenchmarkReporter::Run> ComputeBigO(
31*58b9f456SAndroid Build Coastguard Worker     const std::vector<BenchmarkReporter::Run>& reports);
32*58b9f456SAndroid Build Coastguard Worker 
33*58b9f456SAndroid Build Coastguard Worker // This data structure will contain the result returned by MinimalLeastSq
34*58b9f456SAndroid Build Coastguard Worker //   - coef        : Estimated coeficient for the high-order term as
35*58b9f456SAndroid Build Coastguard Worker //                   interpolated from data.
36*58b9f456SAndroid Build Coastguard Worker //   - rms         : Normalized Root Mean Squared Error.
37*58b9f456SAndroid Build Coastguard Worker //   - complexity  : Scalability form (e.g. oN, oNLogN). In case a scalability
38*58b9f456SAndroid Build Coastguard Worker //                   form has been provided to MinimalLeastSq this will return
39*58b9f456SAndroid Build Coastguard Worker //                   the same value. In case BigO::oAuto has been selected, this
40*58b9f456SAndroid Build Coastguard Worker //                   parameter will return the best fitting curve detected.
41*58b9f456SAndroid Build Coastguard Worker 
42*58b9f456SAndroid Build Coastguard Worker struct LeastSq {
LeastSqLeastSq43*58b9f456SAndroid Build Coastguard Worker   LeastSq() : coef(0.0), rms(0.0), complexity(oNone) {}
44*58b9f456SAndroid Build Coastguard Worker 
45*58b9f456SAndroid Build Coastguard Worker   double coef;
46*58b9f456SAndroid Build Coastguard Worker   double rms;
47*58b9f456SAndroid Build Coastguard Worker   BigO complexity;
48*58b9f456SAndroid Build Coastguard Worker };
49*58b9f456SAndroid Build Coastguard Worker 
50*58b9f456SAndroid Build Coastguard Worker // Function to return an string for the calculated complexity
51*58b9f456SAndroid Build Coastguard Worker std::string GetBigOString(BigO complexity);
52*58b9f456SAndroid Build Coastguard Worker 
53*58b9f456SAndroid Build Coastguard Worker }  // end namespace benchmark
54*58b9f456SAndroid Build Coastguard Worker 
55*58b9f456SAndroid Build Coastguard Worker #endif  // COMPLEXITY_H_
56