一些可能常用的工具函数
- 返回当前的微秒数, 1s = 1000ms,1ms = 1000us
-
// 返回当前时间的微秒
-
long GetCurrentTime(){
-
timeval tv;
-
gettimeofday(&tv,nullptr);
-
return tv.tv_sec * 1000000 + tv.tv_usec;
-
}
- 将文件内容读到 string 里面
-
ifstream in("test.txt",ios::in);
-
istreambuf_iterator<char> beg(in), end;
-
string content(beg, end);
-
in.close();
-
printf("content : %s\n",content.c_str());