From 7fb84dbbc87bdef70dda6ad819dd7e911762eea8 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 12 Oct 2015 02:15:50 +0000 Subject: [PATCH] Add statistics functions --- mkfile | 7 ++++-- spades.awk | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/mkfile b/mkfile index b1ef8c4..ed945c1 100644 --- a/mkfile +++ b/mkfile @@ -7,9 +7,12 @@ CPPFLAGS = -I/usr/include/awk \ -DHAVE_STDBOOL_H \ -DHAVE_STDDEF_H -default: select.so +default:V: stats -test:Q: +stats:QV: + awk -f stats.awk + +test:QV: rm -f var/sp_cur.json #awk -f rhawk < testirc.txt #awk -f rhawk < testirc.txt diff --git a/spades.awk b/spades.awk index a824464..613976b 100644 --- a/spades.awk +++ b/spades.awk @@ -379,6 +379,63 @@ function sp_play(card, winner, pi) } } +# Statistics +function sp_delay(sec) +{ + return (sec > 60*60*24 ? int(sec/60/60/24) "d " : "") \ + (sec > 60*60 ? int(sec/60/60)%24 "h " : "") \ + int(sec/60)%60 "m" +} + +function sp_max(list, i, max) +{ + for (i=0; i max) + max = list[i] + return max +} + +function sp_avg(list, i, sum) +{ + for (i=0; i