Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- powertop_orig/src/main.cpp 2013-07-04 13:03:22.338968093 +1000
- +++ powertop/src/main.cpp 2013-07-04 11:06:33.062885598 +1000
- @@ -53,6 +53,7 @@
- #include "tuning/tuning.h"
- +#include "tuning/tunable.h"
- #include "display.h"
- #include "devlist.h"
- @@ -71,6 +72,7 @@
- {"version", no_argument, NULL, 'V'},
- {"help",no_argument, NULL, 'u'}, /* u for usage */
- {"calibrate",no_argument, NULL, 'c'},
- + {"tune-all",no_argument, NULL, 'a'}, /* a for all */
- {"html", optional_argument, NULL, 'h'},
- {"csv", optional_argument, NULL, 'C'},
- {"extech", optional_argument, NULL, 'e'},
- @@ -106,6 +108,7 @@
- printf("--debug \t\t %s\n",_("run in \"debug\" mode"));
- printf("--version \t\t %s\n",_("print version information"));
- printf("--calibrate \t\t %s\n",_("runs powertop in calibration mode"));
- + printf("--tune-all \t\t %s\n",_("Sets all tunable options to their GOOD setting"));
- printf("--extech%s \t %s\n",_("[=devnode]"),_("uses an Extech Power Analyzer for measurements"));
- printf("--html%s \t %s\n",_("[=FILENAME]"),_("generate a html report"));
- printf("--csv%s \t %s\n",_("[=FILENAME]"),_("generate a csv report"));
- @@ -332,6 +335,55 @@
- initialized = 1;
- }
- +void cleanup(void)
- +{
- + end_process_data();
- + clear_process_data();
- + end_cpu_data();
- + clear_cpu_data();
- +
- + save_all_results("saved_results.powertop");
- + save_parameters("saved_parameters.powertop");
- + learn_parameters(500, 0);
- + save_parameters("saved_parameters.powertop");
- + end_pci_access();
- + clear_tuning();
- +
- + clear_all_devices();
- + clear_all_cpus();
- +}
- +
- +void set_tunables(void)
- +{
- + learn_parameters(250, 0);
- + one_measurement(1, NULL);
- + initialize_tuning();
- +
- + std::cout << "Attempting to tune all settings to GOOD..." << std::endl;
- +
- + std::vector<tunable *>::iterator it;
- + for(it=all_tunables.begin(); it != all_tunables.end(); it++)
- + {
- + tunable *t = *it;
- + switch(t->good_bad())
- + {
- + case TUNE_GOOD:
- + break;
- + case TUNE_BAD:
- + t->toggle();
- + break;
- + case TUNE_UNFIXABLE:
- + break;
- + default:
- + break;
- + }
- +
- + std::cout << t->result_string() << " "
- + << t->description() << std::endl;
- + }
- +
- + cleanup();
- +}
- int main(int argc, char **argv)
- {
- @@ -348,7 +400,7 @@
- textdomain (PACKAGE);
- while (1) { /* parse commandline options */
- - c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index);
- + c = getopt_long (argc, argv, "ch:C:i:t:uVaw:q", long_options, &option_index);
- /* Detect the end of the options. */
- if (c == -1)
- break;
- @@ -367,6 +419,12 @@
- print_usage();
- exit(0);
- break;
- +
- + case 'a': /* set all tunables */
- + powertop_init();
- + set_tunables();
- + exit(0);
- + break;
- case 'c':
- powertop_init();
- @@ -439,21 +497,8 @@
- endwin();
- printf("%s\n", _("Leaving PowerTOP"));
- - end_process_data();
- - clear_process_data();
- - end_cpu_data();
- - clear_cpu_data();
- -
- - save_all_results("saved_results.powertop");
- - save_parameters("saved_parameters.powertop");
- - learn_parameters(500, 0);
- - save_parameters("saved_parameters.powertop");
- - end_pci_access();
- - clear_tuning();
- + cleanup();
- reset_display();
- - clear_all_devices();
- - clear_all_cpus();
- -
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement