1.使用的系统环境
2.lua 和C/C++性能差异 (字符串查找跑5000w次 对比下执行时间)
lua代码:
begin = os.clock();
str = "Hello! My name is Jack. What is your name?"
i = 0
while i <= 50000000 do
string.find(str,"Jack")
i=i+1;
end
print('The program use ', os.clock()-begin, 's');
结果:
C代码:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
char str1[] = "Hello! My name is Jack. What is your name?";
char str2[] = "Jack";
time_t begin, over;
int i = 0;
time(&begin);