Skip to content

Commit b95fb91

Browse files
committed
Update flush_cache for Linux
1 parent 92f7c84 commit b95fb91

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

examples/benchmark_read.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ double compute_variance(double* x, size_t n) {
4343
void flush_cache() {
4444
#ifdef __APPLE__
4545
system("bash -c \"sync && sudo purge\"");
46+
#elif __LINUX__
47+
system("bash -c \"sync\" && sudo echo 3 > /proc/sys/vm/drop_caches");
4648
#else
4749
static_assert(false);
4850
#endif

examples/benchmark_write.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ double compute_variance(double* x, size_t n) {
4343
void flush_cache() {
4444
#ifdef __APPLE__
4545
system("bash -c \"sync && sudo purge\"");
46+
#elif __LINUX__
47+
system("bash -c \"sync\" && sudo echo 3 > /proc/sys/vm/drop_caches");
4648
#else
4749
static_assert(false);
4850
#endif
@@ -51,6 +53,8 @@ void flush_cache() {
5153
void flush_writes() {
5254
#ifdef __APPLE__
5355
system("bash -c \"sync\"");
56+
#elif __LINUX__
57+
system("bash -c \"sync\"");
5458
#else
5559
static_assert(false);
5660
#endif

0 commit comments

Comments
 (0)