summaryrefslogtreecommitdiffstats
path: root/read.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-07-26 17:16:10 +0200
committerLouis Burda <quent.burda@gmail.com>2022-07-26 17:16:10 +0200
commit8dc6462e70009c0bbcf0bbfcfd2d4494d3772580 (patch)
treeccec0043527663246b27ccebc598a68cb61681e7 /read.c
parent2558cb66b59aae1578fc46ff8edf5d7cf9383037 (diff)
downloadcachepc-8dc6462e70009c0bbcf0bbfcfd2d4494d3772580.tar.gz
cachepc-8dc6462e70009c0bbcf0bbfcfd2d4494d3772580.zip
Single eviction test with sleep
Diffstat (limited to 'read.c')
-rw-r--r--read.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/read.c b/read.c
new file mode 100644
index 0000000..28d7b8a
--- /dev/null
+++ b/read.c
@@ -0,0 +1,31 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <assert.h>
+#include <unistd.h>
+
+int
+main(int argc, const char **argv)
+{
+ uint16_t counts[64];
+ size_t i, len;
+ int fd;
+
+ fd = open("/proc/cachepc", O_RDONLY);
+ len = read(fd, counts, sizeof(counts));
+ assert(len == sizeof(counts));
+
+ for (i = 0; i < 64; i++) {
+ if (i % 16 == 0 && i)
+ printf("\n");
+ if (counts[i] > 0)
+ printf("\x1b[91m");
+ printf("%2i ", i);
+ if (counts[i] > 0)
+ printf("\x1b[0m");
+ }
+ printf("\n");
+
+ close(fd);
+}