GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/crocoddyl/core/utils/stop-watch.cpp Lines: 10 22 45.5 %
Date: 2024-02-13 11:12:33 Branches: 0 0 - %

Line Branch Exec Source
1
///////////////////////////////////////////////////////////////////////////////
2
// BSD 3-Clause License
3
//
4
// Copyright (C) 2021, LAAS-CNRS, University of Edinburgh, University of Trento
5
// Copyright note valid unless otherwise stated in individual files.
6
// All rights reserved.
7
///////////////////////////////////////////////////////////////////////////////
8
9
#include "crocoddyl/core/utils/stop-watch.hpp"
10
11
#include "python/crocoddyl/core/core.hpp"
12
13
namespace bp = boost::python;
14
using namespace boost::python;
15
16
namespace crocoddyl {
17
namespace python {
18
19
void enable_report() { getProfiler().enable_profiler(); }
20
21
void disable_report() { getProfiler().disable_profiler(); }
22
23
void stop_watch_report(int precision) { getProfiler().report_all(precision); }
24
25
long double stop_watch_get_average_time(const std::string& perf_name) {
26
  return getProfiler().get_average_time(perf_name);
27
}
28
29
/** Returns minimum execution time of a certain performance */
30
long double stop_watch_get_min_time(const std::string& perf_name) {
31
  return getProfiler().get_min_time(perf_name);
32
}
33
34
/** Returns maximum execution time of a certain performance */
35
long double stop_watch_get_max_time(const std::string& perf_name) {
36
  return getProfiler().get_max_time(perf_name);
37
}
38
39
long double stop_watch_get_total_time(const std::string& perf_name) {
40
  return getProfiler().get_total_time(perf_name);
41
}
42
43
void stop_watch_reset_all() { getProfiler().reset_all(); }
44
45
10
void exposeStopWatch() {
46
10
  bp::def("enable_profiler", enable_report, "Enable the profiler report.");
47
48
10
  bp::def("disable_profiler", enable_report, "Disable the profiler report.");
49
50
10
  bp::def("stop_watch_report", stop_watch_report,
51
          "Report all the times measured by the shared stop-watch.");
52
53
10
  bp::def("stop_watch_get_average_time", stop_watch_get_average_time,
54
          "Get the average time measured by the shared stop-watch for the "
55
          "specified task.");
56
57
10
  bp::def("stop_watch_get_min_time", stop_watch_get_min_time,
58
          "Get the min time measured by the shared stop-watch for the "
59
          "specified task.");
60
61
10
  bp::def("stop_watch_get_max_time", stop_watch_get_max_time,
62
          "Get the max time measured by the shared stop-watch for the "
63
          "specified task.");
64
65
10
  bp::def("stop_watch_get_total_time", stop_watch_get_total_time,
66
          "Get the total time measured by the shared stop-watch for the "
67
          "specified task.");
68
69
10
  bp::def("stop_watch_reset_all", stop_watch_reset_all,
70
          "Reset the shared stop-watch.");
71
10
}
72
73
}  // namespace python
74
}  // namespace crocoddyl