From: Michal Sojka Date: Wed, 12 Aug 2009 16:02:00 +0000 (+0200) Subject: wme_test: GUI may be enabled in both FRSH/non-FRSH version by -G switch X-Git-Url: http://rtime.felk.cvut.cz/gitweb/frescor/fwp.git/commitdiff_plain/790d2d43f403fb980a29dee6ed6324e1b6e710da wme_test: GUI may be enabled in both FRSH/non-FRSH version by -G switch --- diff --git a/wme_test/Makefile.std b/wme_test/Makefile.std index 75ce0d5..58b3f72 100644 --- a/wme_test/Makefile.std +++ b/wme_test/Makefile.std @@ -5,7 +5,7 @@ PROGS = wserver wclient schedlat all: $(PROGS) .PHONY:all -LDFLAGS = -lpthread -lrt +LDFLAGS = -lpthread -lrt -lncurses CFLAGS += -Wall -D_REENTRANT -g -O2 ifdef DEBUG CFLAGS += -DDEBUG=1 diff --git a/wme_test/wclient.c b/wme_test/wclient.c index 6ff81b6..9bcc8e8 100644 --- a/wme_test/wclient.c +++ b/wme_test/wclient.c @@ -21,17 +21,15 @@ #include #include #include +#include #ifdef WITH_FWP #include -#include #include -#include -#include -static UL_LOG_CUST(ulogd); -static ul_log_domain_t ulogd = {UL_LOGL_MSG, "wclient"}; -UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_wclient, ulogd); +/* static UL_LOG_CUST(ulogd); */ +/* static ul_log_domain_t ulogd = {UL_LOGL_MSG, "wclient"}; */ +/* UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_wclient, ulogd); */ #endif @@ -50,6 +48,7 @@ unsigned opt_def_period_msec = 0; int opt_granularity_usec = MIN_GRANULARITY; bool opt_wait_for_queue_is_full; /* Don't gather any statistics until any queue is full */ char *opt_comment = NULL; +bool opt_gui = false; bool some_queue_is_full = false; uint64_t reset_timestamp; /* [nsec] */ @@ -111,12 +110,12 @@ struct stream { frsh_vres_id_t vres, vres_rcv; uint16_t resp_port; struct receiver receiver; - long wc_delay; /* worst-case delay */ #endif /* Statistics */ pthread_mutex_t mutex; unsigned long long sent, really_sent, received; + long wc_delay; /* worst-case delay */ }; static struct cmsg_ipi { @@ -457,11 +456,9 @@ void* receiver(void* arg) } pthread_mutex_unlock(&delay_stats_mutex); -#ifdef WITH_FWP - if (trans_time_usec > stream->wc_delay) { - stream->wc_delay = trans_time_usec; + if (trans_time_usec > streams[msg.stream].wc_delay) { + streams[msg.stream].wc_delay = trans_time_usec; } -#endif receivers[ac].received++; pthread_mutex_lock(&streams[msg.stream].mutex); @@ -530,11 +527,10 @@ send_packet_native(struct stream* stream, union msg_buff* buff) static inline int send_packet_fwp(struct stream* stream, union msg_buff* buff) { - int ret; + int ret = 0; buff->msg.resp_port = htons(stream->resp_port); ret = frsh_send_sync(stream->endpoint, buff, stream->packet_size); - return (ret == 0) ? 0 : -1; } #endif @@ -570,11 +566,11 @@ void* sender(void* arg) struct timespec ts; int ret; -#ifndef WITH_FWP - char stream_desc[100]; - stream_to_text(stream_desc, sizeof(stream_desc), stream, 0); - printf("%s\n", stream_desc); -#endif + if (!opt_gui) { + char stream_desc[100]; + stream_to_text(stream_desc, sizeof(stream_desc), stream, 0); + printf("%s\n", stream_desc); + } if (stream->bandwidth_bps == 0) goto out; @@ -881,10 +877,9 @@ void wait_for_all_threads_to_finish_native(void) } #endif -#ifdef WITH_FWP - WINDOW *logwin; +#if 0 struct log_params { ul_log_domain_t *domain; int level; @@ -922,26 +917,34 @@ wclient_log_fnc(ul_log_domain_t *domain, int level, use_window(logwin, locked_log, (void*)&p); } +#endif void init_gui() { - initscr(); - cbreak(); - noecho(); - - logwin = newwin(0, 0, LINES/2, 0); - if (logwin) { - scrollok(logwin, TRUE); - ul_log_redir(wclient_log_fnc, 0); + if (opt_gui) { + initscr(); + cbreak(); + noecho(); +/* nonl(); */ +/* intrflush(stdscr, FALSE); */ +/* keypad(stdscr, TRUE); */ + + logwin = newwin(0, 0, LINES/2, 0); + if (logwin) { + scrollok(logwin, TRUE); +/* ul_log_redir(wclient_log_fnc, 0); */ + } } } void end_gui() { - endwin(); - if (logwin) { - ul_log_redir(NULL, 0); + if (opt_gui) { + endwin(); + if (logwin) { +/* ul_log_redir(NULL, 0); */ + } } } @@ -955,7 +958,7 @@ void end_gui() addstr(str); \ } -void print_status(int seconds) +void print_status_gui(int seconds) { int i; char str[200], s1[20]; @@ -977,10 +980,8 @@ void print_status(int seconds) wnoutrefresh(stdscr); doupdate(); } -#else -void init_gui() {} -void end_gui() {} -void print_status(int seconds) + +void print_status_nogui(int seconds) { int ac; fprintf(stderr, "\r%3ds", seconds); @@ -991,7 +992,6 @@ void print_status(int seconds) } fflush(stderr); } -#endif int main(int argc, char *argv[]) { @@ -1001,7 +1001,7 @@ int main(int argc, char *argv[]) char opt; - while ((opt = getopt(argc, argv, "B:b:C:c:g:I:j:o:qQ:s:T:")) != -1) { + while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:o:qQ:s:T:")) != -1) { switch (opt) { case 'B': opt_def_bandwidth = atoi(optarg); @@ -1023,6 +1023,9 @@ int main(int argc, char *argv[]) case 'c': opt_count_sec = atoi(optarg); break; + case 'G': + opt_gui = true; + break; case 'g': opt_granularity_usec = atoi(optarg); if (opt_granularity_usec < MIN_GRANULARITY) { @@ -1113,6 +1116,7 @@ int main(int argc, char *argv[]) reset_statistics(); #ifdef WITH_FWP + //ul_log_domain_arg2levels("6"); rc = frsh_init(); if (rc != 0) { error(1, errno, "FWP initialization failed"); @@ -1162,31 +1166,35 @@ int main(int argc, char *argv[]) seconds = 1; frames=0; while (!exit_flag) { -#ifdef WITH_FWP - usleep(40000); -#else - sleep(1); -#endif - frames++; - if (frames>=25) { + if (opt_gui) { + usleep(40000); + frames++; + if (frames>=25) { + seconds++; + frames = 0; + } + print_status_gui(seconds); + } else { + sleep(1); seconds++; - frames = 0; + print_status_nogui(seconds); } - print_status(seconds); + if (seconds == opt_count_sec) stopper(); } } -#ifdef WITH_FWP end_gui(); +#ifdef WITH_FWP for (i=0; i < nr_streams; i++) { if (streams[i].vres) frsh_contract_cancel(streams[i].vres); if (streams[i].vres_rcv) frsh_contract_cancel(streams[i].vres_rcv); } -#else +#endif + fprintf(stderr, "\nWaiting for threads to finish\n"); wait_for_all_threads_to_finish(); @@ -1197,7 +1205,6 @@ int main(int argc, char *argv[]) measure_length = end_timestamp - reset_timestamp; save_results(argc, argv, measure_length/1000); -#endif return 0; }