Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add i915 power estimates to measure subcommand #35

Open
zx2c4 opened this issue Dec 4, 2019 · 0 comments
Open

add i915 power estimates to measure subcommand #35

zx2c4 opened this issue Dec 4, 2019 · 0 comments

Comments

@zx2c4
Copy link

zx2c4 commented Dec 4, 2019

It'd be nice if intel-undervolt measure showed the results from the i915 driver, which is in the same uj output as the current rapl source. Here's some code I just wrote to do it:

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
	FILE *f;
	uint64_t this_microjoules, last_microjoules = ~UINT64_C(0);

	setbuf(stdout, NULL);
	f = fopen("/sys/kernel/debug/dri/0/i915_energy_uJ", "r");
	if (!f) {
		perror("fopen(/sys/kernel/debug/dri/0/i915_energy_uJ)");
		return 1;
	}

	printf("Measuring...");
	for (;;) {
		if (fscanf(f, "%" PRIu64, &this_microjoules) != 1) {
			perror("fscanf");
			return 1;
		}
		rewind(f);
		if (last_microjoules != ~UINT64_C(0))
			printf("\x1b[0G\x1b[0K%.2f W", (double)(this_microjoules - last_microjoules) / 1000000.0);
		last_microjoules = this_microjoules;
		sleep(1);
	}
	return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant