Drake
measure_execution.h
Go to the documentation of this file.
1 #pragma once
2 
3 /// @file
4 /// A benchmarking helper.
5 
6 #include <chrono>
7 #include <utility>
8 
9 namespace drake {
10 namespace common {
11 namespace test {
12 
13 /// Returns the elapsed time of `func(args)`, in seconds.
14 template <typename F, typename... Args>
15 static double MeasureExecutionTime(F func, Args&&... args) {
16  using clock = std::chrono::steady_clock;
17 
18  const clock::time_point start = clock::now();
19  func(std::forward<Args>(args)...);
20  const clock::time_point end = clock::now();
21 
22  return std::chrono::duration<double>(end - start).count();
23 }
24 
25 } // namespace test
26 } // namespace common
27 } // namespace drake
std::vector< snopt::doublereal > F
Definition: snopt_solver.cc:59
Definition: automotive_demo.cc:88
static double MeasureExecutionTime(F func, Args &&...args)
Returns the elapsed time of func(args), in seconds.
Definition: measure_execution.h:15
const char * func
Definition: drake_throw.h:16