summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
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();