aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/cpu_time.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/cpu_time.cpp')
-rw-r--r--native/src/cpu_time.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/native/src/cpu_time.cpp b/native/src/cpu_time.cpp
index d003f22..8dde662 100644
--- a/native/src/cpu_time.cpp
+++ b/native/src/cpu_time.cpp
@@ -3,6 +3,8 @@
3#include <sys/time.h> 3#include <sys/time.h>
4#include <sys/resource.h> 4#include <sys/resource.h>
5 5
6#include <cstring>
7
6#include "cpu_time.h" 8#include "cpu_time.h"
7 9
8 10
@@ -47,3 +49,31 @@ double get_cpu_usage(void)
47} 49}
48 50
49#endif 51#endif
52
53
54std::ostream& operator<<(std::ostream &os, const CPUClock &clock)
55{
56 if (clock.get_function())
57 os << clock.get_function() << "::";
58 os << clock.get_name()
59 << ": total=" << clock.get_total() * 1000 << "ms "
60 << "last=" << clock.get_last() * 1000 << "ms "
61 << "average=" << clock.get_average() * 1000 << "ms "
62 << "count=" << clock.get_count();
63 return os;
64}
65
66char *strip_types(const char* pretty_func)
67{
68 char *copy = strdup(pretty_func);
69
70 char *start = strchr(copy, ' ');
71 char *end = strchr(copy, '(');
72
73 if (start)
74 copy = start + 1;
75 if (end)
76 *end = '\0';
77
78 return copy;
79}