Discussion:
[PATCH] 2.1: Allow user to control measurement time out value
Sergey Senozhatsky
2011-06-08 13:07:34 UTC
Permalink
Oops, sorry, wrong Cc in first e-mail. Resent.


Allow user to set measurement time out ([1..32] secs) via 's' switch
in order to keep measurement statistics more relevant (depending
on load).

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky-***@public.gmane.org>

---

diff --git a/main.cpp b/main.cpp
index fae1b0b..38f4aa1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -54,7 +54,7 @@
#include "devlist.h"

int debug_learning = 0;
-
+unsigned time_out = 20;
int leave_powertop = 0;

static const struct option long_options[] =
@@ -87,6 +87,20 @@ static void set_uid()
show_tab(0);
}

+static bool set_time_out()
+{
+ static char buf[4];
+ mvprintw(1, 0, "%s (currently %u): ", _("Set refresh time out"), time_out);
+ memset(buf, '\0', sizeof(buf));
+ get_user_input(buf, sizeof(buf) - 1);
+ show_tab(0);
+ unsigned time = strtoul(buf, NULL, 0);
+ if (!time) return 0;
+ if (time > 32) time = 32;
+ time_out = time;
+ return 1;
+}
+
static void print_usage()
{
printf(_("Usage: powertop [OPTIONS]\n\n"));
@@ -141,6 +155,10 @@ static void do_sleep(int seconds)
case 'u':
set_uid();
break;
+ case 's':
+ if (set_time_out())
+ return;
+ break;
case 'r':
window_refresh();
break;
@@ -372,7 +390,7 @@ int main(int argc, char **argv)


while (!leave_powertop) {
- one_measurement(20);
+ one_measurement(time_out);
show_cur_tab();
learn_parameters(15, 0);
}

Loading...