npmgpm
v2.0.11
Published
H5项目性能监控
Readme
功能
H5项目-性能监控
1、获取设备、网络、运行时长情况;
2、页面加载各项指标和详情;
3、Webview、WebGL内存统计;
4、Cocos渲染性能、内存占用详情;
5、http请求的资源详情安装
npm i npmgpm导入
import { performanceMonitoring, PerformanceEnum } from 'npmgpm';调用
// 性能监控
performanceMonitoring.setCallBackReport((str: string) => {
GMain.DataCollection.traceEvent('PerformanceMonitoring', str);
});
performanceMonitoring.start({
url: CONFIG_LOCAL_GATE_LIST?.[0], //http、websocket的地址【用于监控网络延时】
visible: DEBUG >= ENV.LOCAL, //面板是否显示
projectName: '埃及Slots', //项目名
reportCondition: CC_PREVIEW ? '' : `${PerformanceEnum.fps}<20&&${PerformanceEnum.runTime}>120`, //上报条件
reportInterval: 60, //上报时间间隔,缺省10,单位:s
});
// 显示面板
performanceMonitoring.show();
// 隐藏面板(数据仍然监控中,仅不显示面板)
performanceMonitoring.hide();
//获取数据
performanceMonitoring.getData();
//添加自定义数据[Loading、切换场景]
performanceMonitoring.appendData({ loading: 2000 });
兼容性
[浏览器]:https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceTiming#%E6%B5%8F%E8%A7%88%E5%99%A8%E5%85%BC%E5%AE%B9%E6%80%A7
Cocos Creator v2.4.0以上版本注意事项
1、appendData方法中,自定义的key名,必须为英文,不在PerformanceEnum中;
2、hide方法,仅仅只是隐藏面板,但数据仍在监控中;
3、Cocos项目,使用了该包后,左下角的调试面板不再展示;缺陷
1、从未加载、使用的子图,原始路径统计不出来;
2、只有加载该Bundle之后,该Bundle下的资源才能获取到完整、正确原始路径;
3、非resources && 默认Bundle中的资源,也找不到原始路径;版本更新
--- v1.1.1 1) (优化)删除部分日志[服务器上传字符限制];
--- v1.0.13 1)(优化)Cocos统计内存时,剔除已经释放的资源; 2)(添加)触发上报条件的回调;
