Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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
C++ 具有系统时间的CCLog,如NSLog_C++_Xcode_Cocos2d X - Fatal编程技术网

C++ 具有系统时间的CCLog,如NSLog

C++ 具有系统时间的CCLog,如NSLog,c++,xcode,cocos2d-x,C++,Xcode,Cocos2d X,为了检查代码的效率,我需要知道执行代码所花费的时间。使用NSlog很容易知道,因为它显示的时间高达毫秒。如何通过CClog实现这一点 示例NSLog 2013-12-03 10:11:58.091 xxxx[12786:c07] START.... 2013-12-03 10:12:04.281 xxxx 在CCLog中刚刚 Cocos2d: 在CCCommon.mm中 替换这个 void CCLog(const char * pszFormat, ...) { print

为了检查代码的效率,我需要知道执行代码所花费的时间。使用NSlog很容易知道,因为它显示的时间高达毫秒。如何通过CClog实现这一点

示例NSLog

 2013-12-03 10:11:58.091 xxxx[12786:c07] START....
 2013-12-03 10:12:04.281 xxxx
在CCLog中刚刚

 Cocos2d:
在CCCommon.mm中

替换这个

void CCLog(const char * pszFormat, ...)

{

    printf("Cocos2d: ");
    char szBuf[kMaxLogLen+1] = {0};
    va_list ap;
    va_start(ap, pszFormat);
    vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
    va_end(ap);
    printf("%s", szBuf);
    printf("\n");
}
对此

void CCLog(const char * pszFormat, ...)

{

    //printf("Cocos2d: ");
    char szBuf[kMaxLogLen+1] = {0};
    va_list ap;
    va_start(ap, pszFormat);
    vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
    va_end(ap);
    //printf("%s", szBuf);
    //printf("\n");

    NSLog(@"%s", szBuf);
}
在CCCommon.mm中

替换这个

void CCLog(const char * pszFormat, ...)

{

    printf("Cocos2d: ");
    char szBuf[kMaxLogLen+1] = {0};
    va_list ap;
    va_start(ap, pszFormat);
    vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
    va_end(ap);
    printf("%s", szBuf);
    printf("\n");
}
对此

void CCLog(const char * pszFormat, ...)

{

    //printf("Cocos2d: ");
    char szBuf[kMaxLogLen+1] = {0};
    va_list ap;
    va_start(ap, pszFormat);
    vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
    va_end(ap);
    //printf("%s", szBuf);
    //printf("\n");

    NSLog(@"%s", szBuf);
}

这是答案…这是答案…似乎过时了。最近有什么消息吗?使用cocos2d-x 3.5似乎过时了。最近有什么消息吗?使用cocos2d-x 3.5