| 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 | #define SCALAR_float32 | ||
| 14 | |||
| 15 | namespace bp = boost::python; | ||
| 16 | using namespace boost::python; | ||
| 17 | |||
| 18 | namespace crocoddyl { | ||
| 19 | namespace python { | ||
| 20 | |||
| 21 | ✗ | void enable_report() { getProfiler().enable_profiler(); } | |
| 22 | |||
| 23 | ✗ | void disable_report() { getProfiler().disable_profiler(); } | |
| 24 | |||
| 25 | ✗ | void stop_watch_report(int precision) { getProfiler().report_all(precision); } | |
| 26 | |||
| 27 | ✗ | long double stop_watch_get_average_time(const std::string& perf_name) { | |
| 28 | ✗ | return getProfiler().get_average_time(perf_name); | |
| 29 | } | ||
| 30 | |||
| 31 | /** Returns minimum execution time of a certain performance */ | ||
| 32 | ✗ | long double stop_watch_get_min_time(const std::string& perf_name) { | |
| 33 | ✗ | return getProfiler().get_min_time(perf_name); | |
| 34 | } | ||
| 35 | |||
| 36 | /** Returns maximum execution time of a certain performance */ | ||
| 37 | ✗ | long double stop_watch_get_max_time(const std::string& perf_name) { | |
| 38 | ✗ | return getProfiler().get_max_time(perf_name); | |
| 39 | } | ||
| 40 | |||
| 41 | ✗ | long double stop_watch_get_total_time(const std::string& perf_name) { | |
| 42 | ✗ | return getProfiler().get_total_time(perf_name); | |
| 43 | } | ||
| 44 | |||
| 45 | ✗ | void stop_watch_reset_all() { getProfiler().reset_all(); } | |
| 46 | |||
| 47 | ✗ | void exposeStopWatch() { | |
| 48 | #ifdef SCALAR_float64 | ||
| 49 | bp::def("enable_profiler", enable_report, "Enable the profiler report."); | ||
| 50 | |||
| 51 | bp::def("disable_profiler", enable_report, "Disable the profiler report."); | ||
| 52 | |||
| 53 | bp::def("stop_watch_report", stop_watch_report, | ||
| 54 | "Report all the times measured by the shared stop-watch."); | ||
| 55 | |||
| 56 | bp::def("stop_watch_get_average_time", stop_watch_get_average_time, | ||
| 57 | "Get the average time measured by the shared stop-watch for the " | ||
| 58 | "specified task."); | ||
| 59 | |||
| 60 | bp::def("stop_watch_get_min_time", stop_watch_get_min_time, | ||
| 61 | "Get the min time measured by the shared stop-watch for the " | ||
| 62 | "specified task."); | ||
| 63 | |||
| 64 | bp::def("stop_watch_get_max_time", stop_watch_get_max_time, | ||
| 65 | "Get the max time measured by the shared stop-watch for the " | ||
| 66 | "specified task."); | ||
| 67 | |||
| 68 | bp::def("stop_watch_get_total_time", stop_watch_get_total_time, | ||
| 69 | "Get the total time measured by the shared stop-watch for the " | ||
| 70 | "specified task."); | ||
| 71 | |||
| 72 | bp::def("stop_watch_reset_all", stop_watch_reset_all, | ||
| 73 | "Reset the shared stop-watch."); | ||
| 74 | #endif | ||
| 75 | ✗ | } | |
| 76 | |||
| 77 | } // namespace python | ||
| 78 | } // namespace crocoddyl | ||
| 79 |