benchmark/src/complexity.h

62 lines
2.3 KiB
C
Raw Normal View History

2016-05-26 04:57:52 +08:00
// Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Source project : https://github.com/ismaelJimenez/cpp.leastsq
// Adapted to be used with google benchmark
2016-05-24 04:31:40 +08:00
#ifndef COMPLEXITY_H_
#define COMPLEXITY_H_
#include <string>
2016-05-26 04:57:52 +08:00
#include <vector>
2016-05-24 04:31:40 +08:00
#include "benchmark/benchmark_api.h"
#include "benchmark/reporter.h"
2016-05-24 04:31:40 +08:00
namespace benchmark {
2016-05-24 04:31:40 +08:00
2016-06-03 01:42:08 +08:00
// Return a vector containing the mean and standard devation information for
// the specified list of reports. If 'reports' contains less than two
// non-errored runs an empty vector is returned
std::vector<BenchmarkReporter::Run> ComputeStats(
const std::vector<BenchmarkReporter::Run>& reports);
2016-06-03 01:42:08 +08:00
// Return a vector containing the bigO and RMS information for the specified
// list of reports. If 'reports.size() < 2' an empty vector is returned.
std::vector<BenchmarkReporter::Run> ComputeBigO(
const std::vector<BenchmarkReporter::Run>& reports);
2016-05-26 04:57:52 +08:00
// This data structure will contain the result returned by MinimalLeastSq
// - coef : Estimated coeficient for the high-order term as
// interpolated from data.
// - rms : Normalized Root Mean Squared Error.
// - complexity : Scalability form (e.g. oN, oNLogN). In case a scalability
// form has been provided to MinimalLeastSq this will return
// the same value. In case BigO::oAuto has been selected, this
// parameter will return the best fitting curve detected.
struct LeastSq {
LeastSq() : coef(0.0), rms(0.0), complexity(oNone) {}
2016-05-26 04:57:52 +08:00
double coef;
double rms;
2016-05-27 03:26:43 +08:00
BigO complexity;
2016-05-26 04:57:52 +08:00
};
2016-05-26 05:33:25 +08:00
// Function to return an string for the calculated complexity
2016-05-27 03:26:43 +08:00
std::string GetBigOString(BigO complexity);
2016-05-26 04:57:52 +08:00
} // end namespace benchmark
#endif // COMPLEXITY_H_