Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ # Generate 8 MB of random data
- $ head -c 8M < /dev/urandom > data.txt
- $ # Flush and clear the cache so we get the data from disk
- $ sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && cargo script posix_fadvise_test.rs
- 3
- Compiling posix_fadvise_test v0.1.0 (file:///home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286)
- Advised result: HashResult { hash: [173, 168, 157, 204, 185, 126, 165, 177, 195, 111, 94, 179, 252, 59, 25, 169], time: Duration { secs: 0, nanos: 10050785 } }
- $ # Comment out the call to advise_willneed, save, flush again and re-run
- $ sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && cargo script posix_fadvise_test.rs
- 3
- Compiling posix_fadvise_test v0.1.0 (file:///home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286)
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:40:1: 53:2 warning: function is never used: `advise_willneed`, #[warn(dead_code)] on by default
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:40 fn advise_willneed(file: &File) {
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:41 let len = file.metadata().unwrap().len();
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:42
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:43 unsafe {
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:44 assert_eq!(
- /home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286/posix_fadvise_test.rs:45 libc::posix_fadvise(
- ...
- Advised result: HashResult { hash: [173, 168, 157, 204, 185, 126, 165, 177, 195, 111, 94, 179, 252, 59, 25, 169], time: Duration { secs: 0, nanos: 33213398 } }
- $ # Significantly slower!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement