Limit running time by an ENV variable
parent
c67a2305ca
commit
3edf611a3e
|
@ -2,6 +2,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -59,7 +61,10 @@ void get_primes7(int n, vector<int> &res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
while (1) {
|
std::time_t startTime = std::time(NULL);
|
||||||
|
std::time_t periodTime = (std::time_t) atoi(std::getenv("RUN_TIME"));
|
||||||
|
|
||||||
|
while ((std::time(NULL) - startTime) < periodTime) {
|
||||||
vector<int> res;
|
vector<int> res;
|
||||||
get_primes7(10000000, res);
|
get_primes7(10000000, res);
|
||||||
printf("Found %d prime numbers.\n", (int)res.size());
|
printf("Found %d prime numbers.\n", (int)res.size());
|
||||||
|
|
Loading…
Reference in New Issue