我在 Eclipse-Ubuntu 上写了两个简单的程序来测试 ulimit 终端命令(附上他们的二进制文件)++++++++++++++++++++++++++++++ ++ 迭代器
#include<iostream>
using namespace std;
int main(){
for(long long i = 0;;i++)
cout << i << endl;
return 0;
}
++++++++++++++++++++++++++++++++++ 定时器
#include<iostream>
#include<time.h>
using namespace std;
clock_t start;
int main(){
start = clock();
for(long long i = 0;;i++)
cout << i << " in " << (double)(clock()-start)/(double)CLOCKS_PER_SEC << "seconds" << endl;
return 0;
}
++++++++++++++++++++++++++++++++++ 测试计时器
+ulimit -t 0; '[PATH]\timer
输出结束
116997 in 1.06seconds
Killed
'+ulimit -t 1; '[PATH]\timer
输出结束
102501 in 0.96seconds
Killed
'+ulimit -t 2; '[PATH]\timer
输出结束
[TEST 1]133073 in 1.19seconds
Killed
[TEST 2]101894 in 1seconds
Killed
[TEST 3]100950 in 0.96seconds
Killed
[TEST 4]126723 in 1.13seconds
Killed
[TEST 5 after opening a new terminal session]229302 in 2.14seconds
Killed
'+ulimit -t 5; '[PATH]\timer
输出结束
**[TEST 1]219295 in 1.99seconds
Killed**
**[TEST 2 ater opening a new session]603088 in 5.47seconds
Killed**
++++++++++++++++++++++++++++++++++ 测试迭代器
+ulimit -t 0; '[PATH]\iterator'
输出结束
200412
Killed
+ulimit -t 1; '[PATH]\iterator'
输出结束
199462
Killed
+ulimit -t 2; '[PATH]\iterator'
输出结束
206111
Killed
+ulimit -t 5; '[PATH]\iterator'
输出结束
244284
Killed
你认为是什么问题?似乎新的终端会话设置了新的时间限制提前谢谢