summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2012-09-05 22:20:51 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2012-09-05 22:20:51 +0300
commit58793683634e9d7428985dcbf9e5aead482da7ff (patch)
tree2f7324973f7e5bacd2168071baa47e24d490aeda
parent734d0739fc05fed44733124d47dd983474fd8038 (diff)
modified: heavy_loader.cppcpu_heavy_loader
-rw-r--r--heavy_loader.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/heavy_loader.cpp b/heavy_loader.cpp
index d4a3744..73b8e1f 100644
--- a/heavy_loader.cpp
+++ b/heavy_loader.cpp
@@ -69,33 +69,36 @@ public:
{
CURL *curl = NULL;
curl = curl_easy_init();
- if(!curl)
- return;
- std::string url = s;
- url += "/";
- url += get_random(5);
- url += "/";
- url += get_random(3);
- curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- curl_easy_setopt(curl, CURLOPT_USERAGENT, "tuk-tuk/0.1");
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2);
- //curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1);
- curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_data_callback);
+
+ while(true)
+ {
+ if(!curl)
+ return;
+ std::string url = s;
+ url += "/";
+ url += get_random(5);
+ url += "/";
+ url += get_random(3);
+ curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, "tuk-tuk/0.1");
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2);
+ //curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1);
+ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_data_callback);
- time_t start = time(0);
+ time_t start = time(0);
- CURLcode error = curl_easy_perform(curl);
+ CURLcode error = curl_easy_perform(curl);
- if(!error)
- success_threads++;
+ if(!error)
+ success_threads++;
- double t = time(0) - start;
+ double t = time(0) - start;
- curl_easy_cleanup(curl);
- c->finished = true;
+ //curl_easy_cleanup(curl);
+ }
}
const std::string s;
@@ -126,7 +129,7 @@ int main(int argc, char *argv[])
int max_threads = atoi(argv[2]);
for(;;)
{
- while(threads.size() >= max_threads)
+ /*while(threads.size() >= max_threads)
{
for(std::list<curl_test>::iterator i = threads.begin(), end = threads.end(); i != end; ++i)
{
@@ -136,12 +139,16 @@ int main(int argc, char *argv[])
i = threads.begin(), end = threads.end();
}
}
- boost::this_thread::sleep(boost::posix_time::milliseconds(10));
- }
+
+ }*/
+ boost::this_thread::sleep(boost::posix_time::milliseconds(100));
try{
+ if(threads.size() < max_threads)
+ {
threads.push_back(curl_test(argv[1]));
threads.back().start();
}
+ }
catch(const std::exception &e)
{
failed_threads++;