Skip to content

Commit

Permalink
Added file.sync_data() so the time reported is more accurate (#1)
Browse files Browse the repository at this point in the history
Closes #1 and tracks the transfer time more accurate by flushing the kernel cache
  • Loading branch information
sourlemon207 committed Nov 10, 2020
1 parent 00af295 commit 94f7f22
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
56 changes: 27 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/main.rs
Expand Up @@ -169,8 +169,13 @@ fn write_once(buffer: &[u8]) -> std::io::Result<Duration> {
let mut file = File::create("test").expect("Can't open test file");

for _ in 0..TOTAL_SIZE_MB / BUF_SIZE_MB {
write_time += prof! {
// make sure the data is synced with the disk as the kernel performs
// write buffering
//
// TODO Open the file in O_DSYNC instead to avoid the additional syscall
write_time += prof!{
file.write_all(buffer)?;
file.sync_data()?;
};
print!(".");
stdout().flush()?;
Expand Down

0 comments on commit 94f7f22

Please sign in to comment.