美文网首页
NSLog 与 printf 执行效率

NSLog 与 printf 执行效率

作者: bianruifeng | 来源:发表于2021-04-03 21:13 被阅读0次
     CFAbsoluteTime startNSLog = CFAbsoluteTimeGetCurrent();
            for (int i = 0; i < 10000; i++) {
                NSLog(@"%d", i);
            }
            CFAbsoluteTime endNSLog = CFAbsoluteTimeGetCurrent();
            
            CFAbsoluteTime startPrintf = CFAbsoluteTimeGetCurrent();
            for (int i = 0; i < 10000; i++) {
                printf("%d\n", i);
            }
            CFAbsoluteTime endPrintf = CFAbsoluteTimeGetCurrent();
            
            NSLog(@"NSLog time: %lf, printf time: %lf", endNSLog - startNSLog, endPrintf - startPrintf);
    

    相关文章

      网友评论

          本文标题:NSLog 与 printf 执行效率

          本文链接:https://www.haomeiwen.com/subject/myohkltx.html