Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c NSTimer性能 我有一个基础CLI工具,它使用5个NSTIMER来执行后台不同的方法。自从实现这些计时器(而不是while循环或类似的)以来,我就注意到程序的CPU使用量猛增。有人知道这方面的信息吗_Objective C_Cocoa_Nstimer - Fatal编程技术网

Objective c NSTimer性能 我有一个基础CLI工具,它使用5个NSTIMER来执行后台不同的方法。自从实现这些计时器(而不是while循环或类似的)以来,我就注意到程序的CPU使用量猛增。有人知道这方面的信息吗

Objective c NSTimer性能 我有一个基础CLI工具,它使用5个NSTIMER来执行后台不同的方法。自从实现这些计时器(而不是while循环或类似的)以来,我就注意到程序的CPU使用量猛增。有人知道这方面的信息吗,objective-c,cocoa,nstimer,Objective C,Cocoa,Nstimer,编辑: 下面是一个代码片段(目前只实现了3个计时器): 你确定你没有不断地创造计时器吗?我不这么认为。我添加了一个编辑,显示计时器的范围。与其猜测,不如使用分析工具进行测量。内置在活动监视器中的一个很容易使用,应该足以让您开始使用。或者考虑使用仪器。 [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(executeInterval0Update) userInfo:nil repeats:YES

编辑:

下面是一个代码片段(目前只实现了3个计时器):


你确定你没有不断地创造计时器吗?我不这么认为。我添加了一个编辑,显示计时器的范围。与其猜测,不如使用分析工具进行测量。内置在活动监视器中的一个很容易使用,应该足以让您开始使用。或者考虑使用仪器。
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(executeInterval0Update) userInfo:nil repeats:YES];
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(executeInterval1Update) userInfo:nil repeats:YES];
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(executeInterval2Update) userInfo:nil repeats:YES];

[runLoop run];