Created
May 17, 2020 11:06
-
-
Save alifarazz/a9dfa35001a5156a9ccb91db6323cf1d to your computer and use it in GitHub Desktop.
Show Cache and Page Info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main() | |
{ | |
puts("L1 I-cache:"); | |
printf("\tSize: %li\n", sysconf(_SC_LEVEL1_ICACHE_SIZE)); | |
printf("\tAssoc: %li\n", sysconf(_SC_LEVEL1_ICACHE_ASSOC)); | |
printf("\tLinesize: %li\n", sysconf(_SC_LEVEL1_ICACHE_LINESIZE)); | |
puts("L1 D-cache:"); | |
printf("\tSize: %li\n", sysconf(_SC_LEVEL1_DCACHE_SIZE)); | |
printf("\tAssoc: %li\n", sysconf(_SC_LEVEL1_DCACHE_ASSOC)); | |
printf("\tLinesize: %li\n", sysconf(_SC_LEVEL1_DCACHE_LINESIZE)); | |
puts("L2 cache:"); | |
printf("\tSize: %li\n", sysconf(_SC_LEVEL2_CACHE_SIZE)); | |
printf("\tAssoc: %li\n", sysconf(_SC_LEVEL2_CACHE_ASSOC)); | |
printf("\tLinesize: %li\n", sysconf(_SC_LEVEL2_CACHE_LINESIZE)); | |
puts("L3 cache:"); | |
printf("\tSize: %li\n", sysconf(_SC_LEVEL3_CACHE_SIZE)); | |
printf("\tAssoc: %li\n", sysconf(_SC_LEVEL3_CACHE_ASSOC)); | |
printf("\tLinesize: %li\n", sysconf(_SC_LEVEL3_CACHE_LINESIZE)); | |
puts("L4 cache:"); | |
printf("\tSize: %li\n", sysconf(_SC_LEVEL4_CACHE_SIZE)); | |
printf("\tAssoc: %li\n", sysconf(_SC_LEVEL4_CACHE_ASSOC)); | |
printf("\tLinesize: %li\n", sysconf(_SC_LEVEL4_CACHE_LINESIZE)); | |
puts("Paging:"); | |
printf("\tPage Size: %li\n", sysconf(_SC_PAGESIZE)); | |
printf("\tNumber of Physical Pages: %li\n", sysconf(_SC_PHYS_PAGES)); | |
printf("\tNumber of Available Physical Pages: %li\n", | |
sysconf(_SC_AVPHYS_PAGES)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment