Current powertop release doesnt give user a help
option and version information .Also there is no
option to specify a time period to collect wakeup stats
while creating a report.
This patch enables the use of -t -h and -v parameters.
Following is a powertop -h output that has been implemented with this patch
-c, --calibrate make estimation more accurate by running a calibration
-t, --time=DOUBLE default time to gather data in seconds
-d, --debug debug learning
-h, --help Show this help message
-r, --html create a powertop.html report
-v, --version Show version information and exit
---
main.cpp | 43 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/main.cpp b/main.cpp
index c5b8a60..270ed0d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -156,9 +156,28 @@ void out_of_memory()
abort();
}
+void usage()
+{
+ printf(_("Usage: powertop [OPTION...]\n"));
+ printf(_(" -c, --calibrate Make estimation more accurate by
running a calibration\n"));
+ printf(_(" -t, --time=DOUBLE Specify the time to gather data in
seconds to be used along with -r\n"));
+ printf(_(" -d, --debug Debug learning\n"));
+ printf(_(" -h, --help Show this help message\n"));
+ printf(_(" -r, --html Create a powertop.html report using
20 seconds of data\n"));
+ printf(_(" -v, --version Show version information and
exit\n"));
+ exit(0);
+}
+
+void version()
+{
+ printf(_("powertop version %s\n"), POWERTOP_VERSION);
+ exit(0);
+}
+
int main(int argc, char **argv)
{
int uid;
+ double ticktime = 20.0;
set_new_handler(out_of_memory);
@@ -196,12 +215,22 @@ int main(int argc, char **argv)
register_parameter("disk-operations", 0.0);
if (argc > 1) {
- if (strcmp(argv[1], "--calibrate") == 0)
+ if (strcmp(argv[1], "--calibrate") == 0 || strcmp(argv[1],
"-c") == 0)
calibrate();
}
if (argc > 1) {
- if (strcmp(argv[1], "--debug") == 0)
+ if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") ==
0)
+ usage();
+ }
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version")
== 0)
+ version();
+ }
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "--debug") == 0 || strcmp(argv[1], "-d") ==
0)
debug_learning = 1;
}
@@ -211,15 +240,19 @@ int main(int argc, char **argv)
}
if (argc > 1) {
- if (strcmp(argv[1], "--html") == 0) {
- fprintf(stderr, _("Measuring for 20 seconds\n"));
+ if (strcmp(argv[1], "--html") == 0 || strcmp(argv[1], "-r") ==
0){
+ if (argc > 2) {
+ ticktime = strtod(argv[2], NULL);
+ }
+
+ fprintf(stderr, _("Measuring for %i seconds\n"),
(int)ticktime);
/* one to warm up everything */
utf_ok = 0;
one_measurement(1);
init_html_output("powertop.html");
initialize_tuning();
/* and then the real measurement */
- one_measurement(20);
+ one_measurement(ticktime);
html_show_tunables();
finish_html_output();
--
1.7.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power