WXTracingManager.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #import <Foundation/Foundation.h>
  20. #import "WXSDKInstance.h"
  21. #define WXTNetworkHanding @"loadJS"
  22. #define WXTExecJS @"execJS"
  23. #define WXTJSCall @"jsCall"
  24. #define WXTDomCall @"domCall"
  25. #define WXTRender @"render"
  26. #define WXTRenderFinish @"renderFinish"
  27. #define WXTJSBridgeThread @"JSThread"
  28. #define WXTDOMThread @"DOMThread"
  29. #define WXTUIThread @"UIThread"
  30. #define WXTMainThread @"MainThread"
  31. #define WXTracingBegin @"B"
  32. #define WXTracingEnd @"E"
  33. #define WXTracingDuration @"D"
  34. #define WXTracingInstant @"i"
  35. #define WXTracingDurationDefault 0
  36. typedef enum : NSUInteger {
  37. // global
  38. WXTracingNetworkHanding = 0,
  39. WXTracingDataHanding,
  40. WXTracingRender
  41. } WXTracingTag;
  42. @interface WXTracingApi:NSObject
  43. @property (nonatomic, copy) NSString *name; //
  44. @property (nonatomic, copy) NSString *className; //
  45. @property (nonatomic, copy) NSString *method; //
  46. @end
  47. @interface WXTracing:NSObject
  48. @property (nonatomic, copy) NSString *ref; // compnonet id
  49. @property (nonatomic, copy) NSString *parentRef; // compnonet id
  50. @property (nonatomic, copy) NSString *className; // compnonet class name or module class name
  51. @property (nonatomic, copy) NSString *name; // register name
  52. @property (nonatomic, copy) NSString *ph; // phase
  53. @property (nonatomic) NSTimeInterval ts; // time
  54. @property (nonatomic) long long traceId;
  55. @property (nonatomic) NSTimeInterval duration;
  56. @property (nonatomic, copy) NSString *fName; // functionName
  57. @property (nonatomic, copy) NSString *iid; // instance id
  58. @property (nonatomic) long long parentId;// parent event id
  59. @property (nonatomic, copy) NSString *bundleUrl;
  60. @property (nonatomic, copy) NSString *threadName;
  61. @property (nonatomic, strong) NSMutableArray *childrenRefs; // children ids
  62. -(NSDictionary *)dictionary;
  63. @end
  64. @interface WXTracingTask:NSObject
  65. @property (nonatomic, copy) NSString *iid;
  66. @property (nonatomic) long long counter;
  67. @property (nonatomic, copy) NSString *tag;
  68. @property (nonatomic, copy) NSString *bundleUrl;
  69. @property (nonatomic, strong) NSMutableArray *tracings;
  70. @property (nonatomic, copy) NSString *bundleJSType; //
  71. @end
  72. @interface WXTracingManager : NSObject
  73. /**
  74. * @discusstion weex perfermance tracing state
  75. * @return isTracing , NO in the release environment.
  76. */
  77. +(BOOL)isTracing;
  78. /**
  79. * @discusstion set weex perfermance tracing state , you should use in debug environment
  80. * @param isTracing YES weex will be traced, NO weex will not be traced .
  81. */
  82. +(void)switchTracing:(BOOL)isTracing;
  83. /**
  84. * @discusstion weex perfermance tracing state
  85. * @param iid the instance id.
  86. * @param ref the component ref
  87. * @param className the module or component class name
  88. * @param name the module or component name
  89. * @param phase the trace phase
  90. * @param functionName function name
  91. * @param options the optional refer:support ts,duration,parentRef
  92. */
  93. +(void)startTracingWithInstanceId:(NSString *)iid ref:(NSString*)ref className:(NSString *)className name:(NSString *)name phase:(NSString *)phase functionName:(NSString *)functionName options:(NSDictionary *)options;
  94. /**
  95. * @discusstion fetch tracing data
  96. * @return the tracing data
  97. */
  98. +(NSMutableDictionary*)getTracingData;
  99. /**
  100. * @discusstion clear tracing data
  101. */
  102. +(void)clearTracingData;
  103. /**
  104. * @discusstion get current time
  105. */
  106. +(NSTimeInterval)getCurrentTime;
  107. /**
  108. * @discusstion set bundle type
  109. * @param jsBundleString the bundle source.
  110. * @param iid the instance id.
  111. */
  112. +(void)setBundleJSType:(NSString *)jsBundleString instanceId:(NSString *)iid;
  113. /**
  114. * @discusstion fetch the weex moudle component handler info
  115. * @return the weex moudle component handler info
  116. */
  117. +(NSDictionary *)getTacingApi;
  118. /**
  119. * @discusstion commit tracing info
  120. * @param instanceId the instance id.
  121. */
  122. +(void )commitTracing:(NSString *)instanceId;
  123. /**
  124. * @discusstion commit summary info
  125. * @param instanceId the instance id.
  126. */
  127. + (void)commitTracingSummaryInfo:(NSDictionary *)info withInstanceId:(NSString *)instanceId;
  128. /**
  129. * @discusstion destroy Traincg Task by Instance
  130. * @param instanceId the instanceId.
  131. */
  132. +(void)destroyTraincgTaskWithInstance:(NSString *)instanceId;
  133. @end