CFAbsoluteTime startTime =CFAbsoluteTimeGetCurrent();
//在这写入要计算时间的代码
...
CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime);
NSLog(@"Linked in %f ms", linkTime *1000.0);
打印出来为代码执行时间 单位ms
OpenGL ES 里面的一段代码
ep:
//START:link
- (BOOL)link
{
CFAbsoluteTime startTime =CFAbsoluteTimeGetCurrent();
GLintstatus;
glLinkProgram(program);
glGetProgramiv(program,GL_LINK_STATUS, &status);
if(status ==GL_FALSE)
returnNO;
if(vertShader)
{
glDeleteShader(vertShader);
vertShader=0;
}
if(fragShader)
{
glDeleteShader(fragShader);
fragShader=0;
}
CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime);
NSLog(@"Linked in %f ms", linkTime *1000.0);
returnYES;
}