大佬教程收集整理的这篇文章主要介绍了ios – iPhone中方法调用的CPU和内存使用情况,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
#define TICK NSDate *startTime = [NSDate date] #define TOCK NSLog(@"Time to process: %f",-[startTime timeIntervalSinceNow])
>从这个SO answer,您可以了解如何获得当前的@L_772_9@使用率.
>从这个SO answer,您可以了解如何获得当前的内存使用情况.
现在你可以产生一个新的线程,定期或按需检查@L_772_9@和内存,然后创建一个类,如下所示:
@interface ProfilerBlock -(id) init; -(void) end; @end
> init方法应初始化当前时间并注册ProfilerBlock实例,以从工作线程获取有关内存使用情况和@L_772_9@使用情况的信息.
> end方法应该计算时间并打印所有需要的信息或将其写入@L_673_22@或其他东西:)
static void __$_Profiler_Block_Release_Object_$__(ProfilerBlock **obj) // the long name is just to prevent duplicated symbol names // { [(*obj) end]; [(*obj) release]; (*obj) = nil; }
最后,您可以创建宏来让您的生活更轻松:
#define CONCAT2(x,y) x ## y #define CONCAT(x,y) CONCAT2(x,y) #define PROFILER_SCOPE_OBjeCT __attribute__((cleanup(__$_Profiler_Block_Release_Object_$__))) #define PROFILE_BLOCK ProfilerBlock *CONCAT(__profilerBlock_,__LINE__) PROFILER_SCOPE_OBjeCT = [[ProfilerBlock alloc] init];
-(void) methodToProfile { PROFILE_BLOCK // add some code to profile here // // the "end" function will get called automatically after the method is done,even if you return early,allowing you to process the profiled data // }
我希望这会有所帮助,对不起,如果我没有详细介绍如何测量内存和@L_772_9@,但我相信其他答案已经很好地介绍了.
以上是大佬教程为你收集整理的ios – iPhone中方法调用的CPU和内存使用情况全部内容,希望文章能够帮你解决ios – iPhone中方法调用的CPU和内存使用情况所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。