diff --git a/TODO b/TODO index f009e84..c429431 100644 --- a/TODO +++ b/TODO @@ -4,4 +4,4 @@ - ssl support - better error reporting - ipv6 support -- progress output +- pipelining diff --git a/src/client.c b/src/client.c index a5733ee..d637ba0 100644 --- a/src/client.c +++ b/src/client.c @@ -275,10 +275,12 @@ void client_state_machine(Client *client) { client->worker->stats.req_failed++; } - /*if (client->worker->id == 1 && (client->worker->stats.req_started % 10) == 0) - printf("thread: %d, requests done: %"PRIu64", %"PRIu64" todo, %"PRIu64" started\n", - client->worker->id, client->worker->stats.req_done, client->worker->stats.req_todo, - client->worker->stats.req_started);*/ + /* print progress every 10% done */ + if (client->worker->id == 1 && client->worker->stats.req_done % client->worker->progress_interval == 0) { + printf("progress: %3d%% done\n", + (int) (client->worker->stats.req_done * 100 / client->worker->stats.req_todo) + ); + } if (client->worker->stats.req_started == client->worker->stats.req_todo) { /* this worker has started all requests */ diff --git a/src/weighttp.c b/src/weighttp.c index 8385c16..b4826b9 100644 --- a/src/weighttp.c +++ b/src/weighttp.c @@ -160,6 +160,7 @@ int main(int argc, char *argv[]) { char c; int err; struct ev_loop *loop; + ev_tstamp ts_start, ts_end; Config config; Worker *worker; char *host; @@ -270,7 +271,7 @@ int main(int argc, char *argv[]) { printf("starting benchmark...\n"); memset(&stats, 0, sizeof(stats)); - stats.ts_start = ev_time(); + ts_start = ev_time(); for (i = 0; i < config.thread_count; i++) { uint64_t reqs = config.req_count / config.thread_count; @@ -325,16 +326,16 @@ int main(int argc, char *argv[]) { worker_free(worker); } - stats.ts_end = ev_time(); - duration = stats.ts_end - stats.ts_start; + ts_end = ev_time(); + duration = ts_end - ts_start; sec = duration; duration -= sec; duration = duration * 1000; millisec = duration; duration -= millisec; microsec = duration * 1000; - rps = stats.req_done / (stats.ts_end - stats.ts_start); - kbps = stats.bytes_total / (stats.ts_end - stats.ts_start) / 1024; + rps = stats.req_done / (ts_end - ts_start); + kbps = stats.bytes_total / (ts_end - ts_start) / 1024; printf("\nfinished in %d sec, %d millisec and %d microsec, %"PRIu64" req/s, %"PRIu64" kbyte/s\n", sec, millisec, microsec, rps, kbps); printf("requests: %"PRIu64" total, %"PRIu64" started, %"PRIu64" done, %"PRIu64" succeeded, %"PRIu64" failed, %"PRIu64" errored\n", config.req_count, stats.req_started, stats.req_done, stats.req_success, stats.req_failed, stats.req_error diff --git a/src/worker.c b/src/worker.c index 3f6fb9c..291981c 100644 --- a/src/worker.c +++ b/src/worker.c @@ -21,6 +21,11 @@ Worker *worker_new(uint8_t id, Config *config, uint16_t num_clients, uint64_t nu worker->config = config; worker->num_clients = num_clients; worker->stats.req_todo = num_requests; + worker->progress_interval = num_requests / 10; + + if (worker->progress_interval == 0) + worker->progress_interval = 1; + worker->clients = W_MALLOC(Client*, num_clients); for (i = 0; i < num_clients; i++) { diff --git a/src/worker.h b/src/worker.h index a62cc32..fd6f041 100644 --- a/src/worker.h +++ b/src/worker.h @@ -9,8 +9,6 @@ */ struct Stats { - ev_tstamp ts_start; /* start of requests */ - ev_tstamp ts_end; /* end of requests */ ev_tstamp req_ts_min; /* minimum time taken for a request */ ev_tstamp req_ts_max; /* maximum time taken for a request */ ev_tstamp req_ts_total; /* total time taken for all requests (this is not ts_end - ts_start!) */ @@ -32,6 +30,7 @@ struct Worker { Client **clients; uint16_t num_clients; Stats stats; + uint64_t progress_interval; };