Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02af3cb5 authored by Dominik Brodowski's avatar Dominik Brodowski
Browse files

cpupowerutils: bench - ConfigStyle bugfixes

parent f5ac0641
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -277,5 +277,4 @@ uninstall:
		rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupowerutils.mo; \
		rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupowerutils.mo; \
	  done;
	  done;


.PHONY: all utils libcpufreq update-po create-gmo install-lib install-tools install-man install-gmo install uninstall \
.PHONY: all utils libcpufreq update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean
	clean 
+29 −19
Original line number Original line Diff line number Diff line
@@ -37,7 +37,7 @@ if (config->output != stdout) { \
 * compute how many rounds of calculation we should do
 * compute how many rounds of calculation we should do
 * to get the given load time
 * to get the given load time
 *
 *
 * @param load aimed load time in s
 * @param load aimed load time in µs
 *
 *
 * @retval rounds of calculation
 * @retval rounds of calculation
 **/
 **/
@@ -62,8 +62,7 @@ unsigned int calculate_timespace(long load, struct config *config)


	/* approximation of the wanted load time by comparing with the
	/* approximation of the wanted load time by comparing with the
	 * initial calculation time */
	 * initial calculation time */
	for (i= 0; i < 4; i++)
	for (i = 0; i < 4; i++) {
	{
		rounds = (unsigned int)(load * estimated / timed);
		rounds = (unsigned int)(load * estimated / timed);
		dprintf("calibrating with %u rounds\n", rounds);
		dprintf("calibrating with %u rounds\n", rounds);
		now = get_time();
		now = get_time();
@@ -130,9 +129,10 @@ void start_benchmark(struct config *config)
		fprintf(config->output, "%u %li %li ",
		fprintf(config->output, "%u %li %li ",
			_round, load_time, sleep_time);
			_round, load_time, sleep_time);


		if (config->verbose) {
		if (config->verbose)
			printf("avarage: %lius, rps:%li\n", load_time / calculations, 1000000 * calculations / load_time);
			printf("avarage: %lius, rps:%li\n",
		}
				load_time / calculations,
				1000000 * calculations / load_time);


		/* do some sleep/load cycles with the performance governor */
		/* do some sleep/load cycles with the performance governor */
		for (cycle = 0; cycle < config->cycles; cycle++) {
		for (cycle = 0; cycle < config->cycles; cycle++) {
@@ -142,10 +142,14 @@ void start_benchmark(struct config *config)
			then = get_time();
			then = get_time();
			performance_time += then - now - sleep_time;
			performance_time += then - now - sleep_time;
			if (config->verbose)
			if (config->verbose)
				printf("performance cycle took %lius, sleep: %lius, load: %lius, rounds: %u\n",
				printf("performance cycle took %lius, "
					(long)(then - now), sleep_time, load_time, calculations);
					"sleep: %lius, "
					"load: %lius, rounds: %u\n",
					(long)(then - now), sleep_time,
					load_time, calculations);
		}
		}
		fprintf(config->output, "%li ", performance_time / config->cycles);
		fprintf(config->output, "%li ",
			performance_time / config->cycles);


		progress_time += sleep_time + load_time;
		progress_time += sleep_time + load_time;
		show_progress(total_time, progress_time);
		show_progress(total_time, progress_time);
@@ -155,7 +159,8 @@ void start_benchmark(struct config *config)
		if (set_cpufreq_governor(config->governor, config->cpu) != 0)
		if (set_cpufreq_governor(config->governor, config->cpu) != 0)
			return;
			return;


		/* again, do some sleep/load cycles with the powersave governor */
		/* again, do some sleep/load cycles with the
		 * powersave governor */
		for (cycle = 0; cycle < config->cycles; cycle++) {
		for (cycle = 0; cycle < config->cycles; cycle++) {
			now = get_time();
			now = get_time();
			usleep(sleep_time);
			usleep(sleep_time);
@@ -163,22 +168,27 @@ void start_benchmark(struct config *config)
			then = get_time();
			then = get_time();
			powersave_time += then - now - sleep_time;
			powersave_time += then - now - sleep_time;
			if (config->verbose)
			if (config->verbose)
				printf("powersave cycle took %lius, sleep: %lius, load: %lius, rounds: %u\n",
				printf("powersave cycle took %lius, "
					(long)(then - now), sleep_time, load_time, calculations);
					"sleep: %lius, "
					"load: %lius, rounds: %u\n",
					(long)(then - now), sleep_time,
					load_time, calculations);
		}
		}


		progress_time += sleep_time + load_time;
		progress_time += sleep_time + load_time;


		/* compare the avarage sleep/load cycles  */
		/* compare the avarage sleep/load cycles  */
		fprintf(config->output, "%li ", powersave_time / config->cycles);
		fprintf(config->output, "%li ",
		fprintf(config->output, "%.3f\n", performance_time * 100.0 / powersave_time);
			powersave_time / config->cycles);
		fprintf(config->output, "%.3f\n",
			performance_time * 100.0 / powersave_time);
		fflush(config->output);
		fflush(config->output);


		if (config->verbose)
		if (config->verbose)
			printf("performance is at %.2f%%\n", performance_time * 100.0 / powersave_time);
			printf("performance is at %.2f%%\n",
				performance_time * 100.0 / powersave_time);


		sleep_time += config->sleep_step;
		sleep_time += config->sleep_step;
		load_time += config->load_step;
		load_time += config->load_step;
	}
	}
}
}
+5 −3
Original line number Original line Diff line number Diff line
@@ -20,7 +20,9 @@
/* load loop, this schould take about 1 to 2ms to complete */
/* load loop, this schould take about 1 to 2ms to complete */
#define ROUNDS(x) {unsigned int rcnt;			       \
#define ROUNDS(x) {unsigned int rcnt;			       \
		for (rcnt = 0; rcnt < x*1000; rcnt++) { \
		for (rcnt = 0; rcnt < x*1000; rcnt++) { \
			(void)(((int)(pow(rcnt, rcnt) * sqrt(rcnt*7230970)) ^ 7230716) ^ (int)atan2(rcnt, rcnt)); \
			(void)(((int)(pow(rcnt, rcnt) * \
				      sqrt(rcnt*7230970)) ^ 7230716) ^ \
				      (int)atan2(rcnt, rcnt));	       \
		} }							\
		} }							\




+1 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,6 @@
#ifdef DEBUG
#ifdef DEBUG
#define dprintf printf
#define dprintf printf
#else
#else
#define dprintf( ... ) while(0) { }
#define dprintf(...) do { } while (0)
#endif
#endif
+3 −4
Original line number Original line Diff line number Diff line
@@ -28,8 +28,7 @@
#include "system.h"
#include "system.h"
#include "benchmark.h"
#include "benchmark.h"


static struct option long_options[] =
static struct option long_options[] = {
{
	{"output",	1,	0,	'o'},
	{"output",	1,	0,	'o'},
	{"sleep",	1,	0,	's'},
	{"sleep",	1,	0,	's'},
	{"load",	1,	0,	'l'},
	{"load",	1,	0,	'l'},
Loading