From e448957c4cc518234d8f6a92219fe649568131d6 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 18 Jan 2025 00:02:36 -0500 Subject: feat: turns out nanosleep and usleep are not part of C99 thus I cannot use them, so I will probably be using time() and getting the diff. created Makefile --- main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index cf8d1ee..3d8223d 100644 --- a/main.c +++ b/main.c @@ -10,13 +10,20 @@ #define CPUINFO "/proc/cpuinfo"; #define CPUFREQ "/sys/devices/system/cpu/cpu0/cpufreq/"; -#define CLEAR "\033[2J"; #define REPOS "\033[H"; // Re-positions the cursor to top left of screen void move(int row, int col) { printf("\x1b[%d;%df", row, col); } +void repos() { + printf("\033[H"); +} + +void clear() { + printf("\033[2J"); +} + void die(const char* reason, int ret) { } @@ -37,7 +44,7 @@ int main(int argc, char** argv) { short cpu = 0; short cores = 0; int samples = 20; - long tdelay = 500000; + unsigned long tdelay = 500000; if ((atoi(argv[1]) != 0) || (strlen(argv[1]) == 1)) { samples = atoi(argv[1]); @@ -63,17 +70,13 @@ int main(int argc, char** argv) { return 1; } } - struct timespec dur; - dur.tv_nsec = tdelay; for (int i = 0; i < samples; i++) { - CLEAR; if (memory) { printmemory(); } if (cpu) { printcpu(); } - nanosleep(&dur, NULL); } if (cores) printcores(); -- cgit v1.2.3