WXMonitor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "WXDefine.h"
  21. #import "WXSDKError.h"
  22. @class WXSDKInstance;
  23. typedef enum : NSUInteger {
  24. // global
  25. WXPTInitalize = 0,
  26. WXPTInitalizeSync,
  27. WXPTFrameworkExecute,
  28. // instance
  29. WXPTJSDownload,
  30. WXPTJSCreateInstance,
  31. WXFirstScreenJSFExecuteTime,
  32. WXPTFirstScreenRender,
  33. WXPTAllRender,
  34. WXPTBundleSize,
  35. //new point
  36. //doc see @WXPerformance
  37. WXPTFsCallJsTime,
  38. WXPTFsCallJsNum,
  39. WXPTFsCallNativeTime,
  40. WXPTFsCallNativeNum,
  41. WXPTFsCallEventNum,
  42. WXPTFsReqNetNum,
  43. WXPTCellExceedNum,
  44. WXPTMaxDeepVDom,
  45. WXPTImgWrongSizeNum,
  46. WXPTTimerNum,
  47. WXPTInteractionTime,
  48. WXPTWrongImgSize,
  49. WXPTInteractionAddCount,
  50. WXPTInteractionLimitAddCount,
  51. WXPTComponentCount,
  52. WXPTComponentCreateTime,
  53. WXPNewFSRenderTime,
  54. //end
  55. WXPTEnd
  56. } WXPerformanceTag;
  57. typedef enum : NSUInteger {
  58. WXMTJSFramework,
  59. WXMTJSDownload,
  60. WXMTJSBridge,
  61. WXMTNativeRender,
  62. WXMTJSService,
  63. } WXMonitorTag;
  64. typedef NS_ENUM(NSInteger, CommitState)
  65. {
  66. MonitorCommit,
  67. //just use on Debug mode
  68. DebugAfterRequest,
  69. DebugAfterFSFinish,
  70. DebugAfterExist,
  71. DebugOnRealTime
  72. };
  73. #define WX_MONITOR_SUCCESS_ON_PAGE(tag, pageName) [WXMonitor monitoringPointDidSuccess:tag onPage:pageName];
  74. #define WX_MONITOR_FAIL_ON_PAGE(tag, errorCode, errorMessage, pageName) \
  75. NSError *error = [NSError errorWithDomain:WX_ERROR_DOMAIN \
  76. code:errorCode \
  77. userInfo:@{NSLocalizedDescriptionKey:(errorMessage?:@"No message")}]; \
  78. [WXMonitor monitoringPoint:tag didFailWithError:error onPage:pageName];
  79. #define WX_MONITOR_SUCCESS(tag) WX_MONITOR_SUCCESS_ON_PAGE(tag, nil)
  80. #define WX_MONITOR_FAIL(tag, errorCode, errorMessage) WX_MONITOR_FAIL_ON_PAGE(tag, errorCode, errorMessage, nil)
  81. #define WX_MONITOR_PERF_START(tag) [WXMonitor performancePoint:tag willStartWithInstance:nil];
  82. #define WX_MONITOR_PERF_END(tag) [WXMonitor performancePoint:tag didEndWithInstance:nil];
  83. #define WX_MONITOR_INSTANCE_PERF_START(tag, instance) [WXMonitor performancePoint:tag willStartWithInstance:instance];
  84. #define WX_MONITOR_INSTANCE_PERF_END(tag, instance) [WXMonitor performancePoint:tag didEndWithInstance:instance];
  85. #define WX_MONITOR_PERF_SET(tag, value, instance) [WXMonitor performancePoint:tag didSetValue:value withInstance:instance];
  86. #define WX_MONITOR_INSTANCE_PERF_IS_RECORDED(tag, instance) [WXMonitor performancePoint:tag isRecordedWithInstance:instance]
  87. #define WX_MONITOR_INSTANCE_PERF_COMMIT(instance) [WXMonitor performanceFinish:instance]
  88. //DEPRECATED_ATTRIBUTE
  89. @interface WXMonitor : NSObject
  90. + (void)performancePoint:(WXPerformanceTag)tag willStartWithInstance:(WXSDKInstance *)instance;
  91. + (void)performancePoint:(WXPerformanceTag)tag didEndWithInstance:(WXSDKInstance *)instance;
  92. + (void)performancePoint:(WXPerformanceTag)tag didSetValue:(double)value withInstance:(WXSDKInstance *)instance;
  93. + (BOOL)performancePoint:(WXPerformanceTag)tag isRecordedWithInstance:(WXSDKInstance *)instance;
  94. + (void)performanceFinish:(WXSDKInstance *)instance;
  95. + (void)monitoringPointDidSuccess:(WXMonitorTag)tag onPage:(NSString *)pageName;
  96. + (void)monitoringPoint:(WXMonitorTag)tag didFailWithError:(NSError *)error onPage:(NSString *)pageName;
  97. + (void)performanceFinishWithState:(CommitState) state instance:(WXSDKInstance *)instance;
  98. @end