summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaochen Wang <wangxiaochen0@gmail.com>2013-10-24 14:54:37 +0800
committerStefan B├╝hler <stbuehler@web.de>2013-10-25 16:34:50 +0200
commit7da292b24288416e72323e4793eeb136338f0df0 (patch)
tree8ea67623cf794d84550cff7c044b5ff862adb916
parentc14ac587e08127f45cb111f37d8481884493303a (diff)
downloadweighttp-7da292b24288416e72323e4793eeb136338f0df0.tar.gz
weighttp-7da292b24288416e72323e4793eeb136338f0df0.zip
calculate concur & reqs more easily
When i is increased to (config.thread_count - 1), rest_concur has been decreased to zero. Therefore diff is always 1 in loop. It is unnecessary to calculate diff.
-rw-r--r--src/weighttp.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/weighttp.c b/src/weighttp.c
index c7670f7..14951a7 100644
--- a/src/weighttp.c
+++ b/src/weighttp.c
@@ -354,20 +354,15 @@ int main(int argc, char *argv[]) {
for (i = 0; i < config.thread_count; i++) {
uint64_t reqs = config.req_count / config.thread_count;
uint16_t concur = config.concur_count / config.thread_count;
- uint64_t diff;
if (rest_concur) {
- diff = (i == config.thread_count) ? rest_concur : (rest_concur / config.thread_count);
- diff = diff ? diff : 1;
- concur += diff;
- rest_concur -= diff;
+ concur += 1;
+ rest_concur -= 1;
}
if (rest_req) {
- diff = (i == config.thread_count) ? rest_req : (rest_req / config.thread_count);
- diff = diff ? diff : 1;
- reqs += diff;
- rest_req -= diff;
+ reqs += 1;
+ rest_req -= 1;
}
printf("spawning thread #%d: %"PRIu16" concurrent requests, %"PRIu64" total requests\n", i+1, concur, reqs);
workers[i] = worker_new(i+1, &config, concur, reqs);