···8686 len += strlen(sysdata.nodename) + strlen(sysdata.release);8787 filename = realloc(filename, sizeof(char) * len);88888989- if(filename == NULL) {8989+ if (filename == NULL) {9090 perror("realloc");9191 return NULL;9292 }93939494- snprintf(filename, len - 1, "%s/benchmark_%s_%s_%li.log", 9494+ snprintf(filename, len - 1, "%s/benchmark_%s_%s_%li.log",9595 dirname, sysdata.nodename, sysdata.release, time(NULL));9696 } else {9797- snprintf(filename, len -1, "%s/benchmark_%li.log", dirname, time(NULL));9797+ snprintf(filename, len - 1, "%s/benchmark_%li.log",9898+ dirname, time(NULL));9899 }99100100101 dprintf("logilename: %s\n", filename);101102102102- if ((output = fopen(filename, "w+")) == NULL) {103103+ output = fopen(filename, "w+");104104+ if (output == NULL) {103105 perror("fopen");104106 fprintf(stderr, "error: unable to open logfile\n");105107 }···132130 config->load_step = 500000;133131 config->cycles = 5;134132 config->rounds = 50;135135- config->cpu = 0; 133133+ config->cpu = 0;136134 config->prio = SCHED_HIGH;137135 config->verbose = 0;138136 strncpy(config->governor, "ondemand", 8);···168166169167 if (configfile == NULL) {170168 perror("fopen");171171- fprintf(stderr, "error: unable to read configfile\n");169169+ fprintf(stderr, "error: unable to read configfile\n");172170 free(config);173171 return 1;174172 }175173176176- while (getline(&line, &len, configfile) != -1)177177- {174174+ while (getline(&line, &len, configfile) != -1) {178175 if (line[0] == '#' || line[0] == ' ')179176 continue;180177···184183 if (strncmp("sleep", opt, strlen(opt)) == 0)185184 sscanf(val, "%li", &config->sleep);186185187187- else if (strncmp("load", opt, strlen(opt)) == 0) 186186+ else if (strncmp("load", opt, strlen(opt)) == 0)188187 sscanf(val, "%li", &config->load);189188190190- else if (strncmp("load_step", opt, strlen(opt)) == 0) 189189+ else if (strncmp("load_step", opt, strlen(opt)) == 0)191190 sscanf(val, "%li", &config->load_step);192191193193- else if (strncmp("sleep_step", opt, strlen(opt)) == 0) 192192+ else if (strncmp("sleep_step", opt, strlen(opt)) == 0)194193 sscanf(val, "%li", &config->sleep_step);195194196196- else if (strncmp("cycles", opt, strlen(opt)) == 0) 195195+ else if (strncmp("cycles", opt, strlen(opt)) == 0)197196 sscanf(val, "%u", &config->cycles);198197199199- else if (strncmp("rounds", opt, strlen(opt)) == 0) 198198+ else if (strncmp("rounds", opt, strlen(opt)) == 0)200199 sscanf(val, "%u", &config->rounds);201200202202- else if (strncmp("verbose", opt, strlen(opt)) == 0) 201201+ else if (strncmp("verbose", opt, strlen(opt)) == 0)203202 sscanf(val, "%u", &config->verbose);204203205205- else if (strncmp("output", opt, strlen(opt)) == 0) 204204+ else if (strncmp("output", opt, strlen(opt)) == 0)206205 config->output = prepare_output(val); 207206208208- else if (strncmp("cpu", opt, strlen(opt)) == 0) 207207+ else if (strncmp("cpu", opt, strlen(opt)) == 0)209208 sscanf(val, "%u", &config->cpu);210209211211- else if (strncmp("governor", opt, 14) == 0) 210210+ else if (strncmp("governor", opt, 14) == 0)212211 strncpy(config->governor, val, 14);213212214213 else if (strncmp("priority", opt, strlen(opt)) == 0) {215215- if (string_to_prio(val) != SCHED_ERR) 214214+ if (string_to_prio(val) != SCHED_ERR)216215 config->prio = string_to_prio(val);217216 }218217 }
+8-5
tools/power/cpupower/bench/parse.h
···2020/* struct that holds the required config parameters */2121struct config2222{2323- long sleep; /* sleep time in �s */2424- long load; /* load time in �s */2323+ long sleep; /* sleep time in µs */2424+ long load; /* load time in µs */2525 long sleep_step; /* time value which changes the2626- * sleep time after every round in �s */2626+ * sleep time after every round in µs */2727 long load_step; /* time value which changes the2828- * load time after every round in �s */2828+ * load time after every round in µs */2929 unsigned int cycles; /* calculation cycles with the same sleep/load time */3030 unsigned int rounds; /* calculation rounds with iterated sleep/load time */3131 unsigned int cpu; /* cpu for which the affinity is set */3232 char governor[15]; /* cpufreq governor */3333 enum sched_prio /* possible scheduler priorities */3434 {3535- SCHED_ERR=-1,SCHED_HIGH, SCHED_DEFAULT, SCHED_LOW3535+ SCHED_ERR = -1,3636+ SCHED_HIGH,3737+ SCHED_DEFAULT,3838+ SCHED_LOW3639 } prio;37403841 unsigned int verbose; /* verbose output */
+8-5
tools/power/cpupower/bench/system.c
···3131#include "system.h"32323333/**3434- * returns time since epoch in �s3434+ * returns time since epoch in µs3535 *3636 * @retval time3737 **/···8787int set_cpu_affinity(unsigned int cpu)8888{8989 cpu_set_t cpuset;9090-9090+9191 CPU_ZERO(&cpuset);9292 CPU_SET(cpu, &cpuset);9393···129129}130130131131/**132132- * notifys the user that the benchmark may run some time 132132+ * notifies the user that the benchmark may run some time133133 *134134 * @param config benchmark config values135135 *···142142 unsigned int round;143143144144 for (round = 0; round < config->rounds; round++) {145145- sleep_time += 2 * config->cycles * (config->sleep + config->sleep_step * round);146146- load_time += 2 * config->cycles * (config->load + config->load_step * round) + (config->load + config->load_step * round * 4);145145+ sleep_time += 2 * config->cycles *146146+ (config->sleep + config->sleep_step * round);147147+ load_time += 2 * config->cycles *148148+ (config->load + config->load_step * round) +149149+ (config->load + config->load_step * round * 4);147150 }148151149152 if (config->verbose || config->output != stdout)