7 #ifndef LIBCARLA_ENABLE_PROFILER 8 # define LIBCARLA_ENABLE_PROFILER 9 #endif // LIBCARLA_ENABLE_PROFILER 12 #include "carla/Version.h" 24 template <
typename Arg,
typename ... Args>
27 << std::left << std::setw(44)
28 << std::forward<Arg>(arg)
30 << std::fixed << std::setprecision(2);
31 using expander =
int[];
32 (void)expander{0, (void(out <<
", " << std::setw(10) << std::forward<Args>(args)),0)...};
41 std::string header =
"# LibCarla Profiler ";
42 header += carla::version();
44 header +=
" (release)";
49 write_line(
"# context",
"average",
"maximum",
"minimum",
"units",
"times");
52 template <
typename ... Args>
54 write_to_file(std::ios_base::app|std::ios_base::out, std::forward<Args>(args)...);
59 template <
typename ... Args>
62 static std::mutex MUTEX;
63 std::lock_guard<std::mutex> guard(MUTEX);
73 ProfilerData::~ProfilerData() {
77 PROFILER.write_line(_name, fps(average()), fps(minimum()), fps(maximum()),
"FPS", _count);
79 PROFILER.write_line(_name, average(), maximum(), minimum(),
"ms", _count);
82 log_error(
"profiler", _name,
" was never run!");
static void log(Args &&... args)
static void log_error(Args &&... args)
This file contains definitions of common data structures used in traffic manager. ...
static void write_csv_to_stream(std::ostream &out, Arg &&arg, Args &&... args)
void write_line(Args &&... args)
const std::string _filename
static LifetimeProfiler PROFILER
void write_to_file(std::ios_base::openmode mode, Args &&... args)
StaticProfiler(std::string filename)