add progress output

This commit is contained in:
Thomas Porzelt 2009-09-13 16:08:15 +02:00
parent 2a8afc8dfb
commit 98278f6de2
5 changed files with 19 additions and 12 deletions

2
TODO
View File

@ -4,4 +4,4 @@
- ssl support - ssl support
- better error reporting - better error reporting
- ipv6 support - ipv6 support
- progress output - pipelining

View File

@ -275,10 +275,12 @@ void client_state_machine(Client *client) {
client->worker->stats.req_failed++; client->worker->stats.req_failed++;
} }
/*if (client->worker->id == 1 && (client->worker->stats.req_started % 10) == 0) /* print progress every 10% done */
printf("thread: %d, requests done: %"PRIu64", %"PRIu64" todo, %"PRIu64" started\n", if (client->worker->id == 1 && client->worker->stats.req_done % client->worker->progress_interval == 0) {
client->worker->id, client->worker->stats.req_done, client->worker->stats.req_todo, printf("progress: %3d%% done\n",
client->worker->stats.req_started);*/ (int) (client->worker->stats.req_done * 100 / client->worker->stats.req_todo)
);
}
if (client->worker->stats.req_started == client->worker->stats.req_todo) { if (client->worker->stats.req_started == client->worker->stats.req_todo) {
/* this worker has started all requests */ /* this worker has started all requests */

View File

@ -160,6 +160,7 @@ int main(int argc, char *argv[]) {
char c; char c;
int err; int err;
struct ev_loop *loop; struct ev_loop *loop;
ev_tstamp ts_start, ts_end;
Config config; Config config;
Worker *worker; Worker *worker;
char *host; char *host;
@ -270,7 +271,7 @@ int main(int argc, char *argv[]) {
printf("starting benchmark...\n"); printf("starting benchmark...\n");
memset(&stats, 0, sizeof(stats)); memset(&stats, 0, sizeof(stats));
stats.ts_start = ev_time(); ts_start = ev_time();
for (i = 0; i < config.thread_count; i++) { for (i = 0; i < config.thread_count; i++) {
uint64_t reqs = config.req_count / config.thread_count; uint64_t reqs = config.req_count / config.thread_count;
@ -325,16 +326,16 @@ int main(int argc, char *argv[]) {
worker_free(worker); worker_free(worker);
} }
stats.ts_end = ev_time(); ts_end = ev_time();
duration = stats.ts_end - stats.ts_start; duration = ts_end - ts_start;
sec = duration; sec = duration;
duration -= sec; duration -= sec;
duration = duration * 1000; duration = duration * 1000;
millisec = duration; millisec = duration;
duration -= millisec; duration -= millisec;
microsec = duration * 1000; microsec = duration * 1000;
rps = stats.req_done / (stats.ts_end - stats.ts_start); rps = stats.req_done / (ts_end - ts_start);
kbps = stats.bytes_total / (stats.ts_end - stats.ts_start) / 1024; 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("\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", 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 config.req_count, stats.req_started, stats.req_done, stats.req_success, stats.req_failed, stats.req_error

View File

@ -21,6 +21,11 @@ Worker *worker_new(uint8_t id, Config *config, uint16_t num_clients, uint64_t nu
worker->config = config; worker->config = config;
worker->num_clients = num_clients; worker->num_clients = num_clients;
worker->stats.req_todo = num_requests; 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); worker->clients = W_MALLOC(Client*, num_clients);
for (i = 0; i < num_clients; i++) { for (i = 0; i < num_clients; i++) {

View File

@ -9,8 +9,6 @@
*/ */
struct Stats { 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_min; /* minimum time taken for a request */
ev_tstamp req_ts_max; /* maximum 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!) */ 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; Client **clients;
uint16_t num_clients; uint16_t num_clients;
Stats stats; Stats stats;
uint64_t progress_interval;
}; };