From: Michal Sojka Date: Tue, 14 Jan 2014 10:17:16 +0000 (+0100) Subject: ugw: Add statistics X-Git-Tag: fix-allnoconfig~80 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/commitdiff_plain/269a6c4ec5cf0aa2aa4b8ce92614a8003c166323 ugw: Add statistics --- diff --git a/ugw/ugw.c b/ugw/ugw.c index 0e653d3..fd4805b 100644 --- a/ugw/ugw.c +++ b/ugw/ugw.c @@ -22,6 +22,7 @@ #include #include #include +#include #ifndef SO_BUSY_POLL #define SO_BUSY_POLL 46 @@ -71,6 +72,18 @@ struct out_ctx { int (*out_fn)(struct out_ctx *ctx, struct can_frame *cf); }; +struct stats { + int store; + int send; +} stats; + +void sigint(int v) +{ + printf("store:%d\nsend:%d\ntotal:%d\n", + stats.store, stats.send, stats.store + stats.send); + exit(0); +} + enum in2out in_read(struct in_ctx *ctx, struct can_frame *cf) { int ret = read(ctx->s, cf, sizeof(*cf)); @@ -396,6 +409,7 @@ int main(int argc, char *argv[]) if (optind+1 < argc) devout = argv[optind+1]; + signal(SIGINT, sigint); gw(); return 0;