54 #include <mach/mach_time.h> 55 static mach_timebase_info_data_t g_time_info;
57 mach_timebase_info(&g_time_info);
62 #if defined(__APPLE__) 64 return t * g_time_info.numer / g_time_info.denom;
67 t.tv_sec = t.tv_nsec = 0;
68 clock_gettime(CLOCK_MONOTONIC, &t);
69 return static_cast<int64_t>(t.tv_sec) * 1000000000LL + t.tv_nsec;
80 const int kRangeMultiplier = 8;
88 lo *= kRangeMultiplier;
104 for (
int i = 1;
i < argc;
i++) {
106 if (
regcomp(&re, argv[
i], 0) != 0) {
107 fprintf(
stderr,
"couldn't compile \"%s\" as a regular expression!\n", argv[i]);
136 for (
size_t i = 0;
i <
args_.size(); ++
i) {
159 int last = iterations;
165 iterations =
std::max(last + 1,
std::min(iterations + iterations/2, 100*last));
166 iterations =
Round(iterations);
169 char throughput[100];
170 throughput[0] =
'\0';
174 snprintf(throughput,
sizeof(throughput),
" %8.2f MFlops/s", mflops_processed/seconds);
178 if (arg >= (1<<20)) {
179 snprintf(full_name,
sizeof(full_name),
"%s/%dM",
name_, arg/(1<<20));
180 }
else if (arg >= (1<<10)) {
181 snprintf(full_name,
sizeof(full_name),
"%s/%dK",
name_, arg/(1<<10));
183 snprintf(full_name,
sizeof(full_name),
"%s/%d",
name_, arg);
186 snprintf(full_name,
sizeof(full_name),
"%s",
name_);
207 int main(
int argc,
char* argv[]) {
209 fprintf(
stderr,
"No benchmarks registered!\n");
213 int name_width =
static_cast<int>(strlen(it->second->Name()));
216 bool need_header =
true;
229 fprintf(
stderr,
"No matching benchmarks!\n");
230 fprintf(
stderr,
"Available benchmarks:\n");
232 fprintf(
stderr,
" %s\n", it->second->Name());
void regfree(regex_t *__preg)
bool match(const T &xpr, std::string ref, std::string str_xpr="")
void StopBenchmarkTiming()
svint32_t PacketXi __attribute__((arm_sve_vector_bits(EIGEN_ARM64_SVE_VL)))
void(* fn_range_)(int, int)
bool ShouldRun(int argc, char *argv[])
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
void StartBenchmarkTiming()
static int g_name_column_width
static int64_t g_flops_processed
void SetBenchmarkFlopsProcessed(int64_t x)
void Register(const char *name, void(*fn)(int), void(*fn_range)(int, int))
int regexec(const regex_t *__restrict __preg, const char *__restrict __string, size_t __nmatch, regmatch_t __pmatch[__restrict_arr], int __eflags)
unsigned __int64 uint64_t
std::map< std::string, ::testing::Benchmark * > BenchmarkMap
void RunRepeatedlyWithArg(int iterations, int arg)
int regcomp(regex_t *__restrict __preg, const char *__restrict __pattern, int __cflags)
static int64_t g_benchmark_total_time_ns
int main(int argc, char *argv[])
Benchmark * Range(int lo, int hi)
BenchmarkMap & gBenchmarks()
BenchmarkMap::iterator BenchmarkMapIt
Annotation for function names.
Annotation indicating that a class derives from another given type.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
static int64_t NanoTime()
static int64_t g_benchmark_start_time_ns