2
2
// Created by Panayot Cankov on 26/05/2017.
3
3
//
4
4
5
- #ifndef TEST_APP_MANUALINSTRUMENTATION_H
6
- #define TEST_APP_MANUALINSTRUMENTATION_H
5
+ #ifndef MANUALINSTRUMENTATION_H
6
+ #define MANUALINSTRUMENTATION_H
7
7
8
8
#include " v8.h"
9
9
#import < chrono>
10
10
#import < NativeScriptAssert.h>
11
+ #include < string>
11
12
12
13
namespace tns {
13
14
namespace instrumentation {
14
15
class Frame {
15
16
public:
16
- inline Frame () : Frame (nullptr ) { }
17
- inline Frame (const char * name) : name (name), start (disabled ? disabled_time : std::chrono::steady_clock::now ()) {}
17
+ inline Frame () : Frame (" " ) { }
18
+ inline Frame (std::string name) : name (name), start (disabled ? disabled_time : std::chrono::steady_clock::now ()) {}
18
19
19
20
inline ~Frame () {
20
- if (name && check ()) {
21
+ if (! name. empty () && check ()) {
21
22
log (name);
22
23
}
23
24
}
@@ -42,6 +43,10 @@ namespace tns {
42
43
__android_log_print (ANDROID_LOG_DEBUG, " JS" , " Timeline: %.3f ms: Runtime: %s (%.3f ms - %.3f ms)" , duration / 1000.0 , message, startMilis, endMilis);
43
44
}
44
45
46
+ inline void log (const std::string& message) {
47
+ log (message.c_str ());
48
+ }
49
+
45
50
static inline void enable () { disabled = false ; }
46
51
static inline void disable () { disabled = true ; }
47
52
@@ -50,7 +55,7 @@ namespace tns {
50
55
static const std::chrono::steady_clock::time_point disabled_time; // Couldn't find reasonable constant
51
56
52
57
const std::chrono::steady_clock::time_point start;
53
- const char * name;
58
+ const std::string name;
54
59
55
60
Frame (const Frame &) = delete;
56
61
Frame &operator=(const Frame &) = delete;
@@ -63,4 +68,4 @@ namespace tns {
63
68
*/
64
69
#define TNSPERF () tns::instrumentation::Frame __tns_manual_instrumentation (__func__)
65
70
66
- #endif // TEST_APP_MANUALINSTRUMENTATION_H
71
+ #endif // MANUALINSTRUMENTATION_H
0 commit comments