summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJosh <eeei3.joshua0307lol@gmail.com>2025-01-18 00:02:36 -0500
committerJosh <eeei3.joshua0307lol@gmail.com>2025-01-18 00:02:36 -0500
commite448957c4cc518234d8f6a92219fe649568131d6 (patch)
treef223eb5abb034ed8770dee2171c23ad62d792f3e /main.c
parentc60e25414b43433ea7275829e0df937cfcff3ebb (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
Diffstat (limited to 'main.c')
-rw-r--r--main.c15
1 files changed, 9 insertions, 6 deletions
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();