diff options
author | Josh <eeei3.joshua0307lol@gmail.com> | 2025-01-18 00:02:36 -0500 |
---|---|---|
committer | Josh <eeei3.joshua0307lol@gmail.com> | 2025-01-18 00:02:36 -0500 |
commit | e448957c4cc518234d8f6a92219fe649568131d6 (patch) | |
tree | f223eb5abb034ed8770dee2171c23ad62d792f3e | |
parent | c60e25414b43433ea7275829e0df937cfcff3ebb (diff) |
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
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | main.c | 15 |
2 files changed, 19 insertions, 6 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..04d0f04 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +PROG=main.c + +all: $(PROG) + gcc -std=c99 -Wall -Werror $(PROG) + +noW: $(PROG) + gcc $(PROG) + +debug: $(PROG) + gcc -g $(PROG) @@ -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(); |