From adce05d59baf2f063244a02efe26f6c7ad9865a2 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Thu, 31 May 2018 09:10:01 +0100 Subject: Fix file_handle::barrier() not working, at all, on Windows. --- programs/benchmark-iostreams/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'programs') diff --git a/programs/benchmark-iostreams/main.cpp b/programs/benchmark-iostreams/main.cpp index 9d192a98..50d5ed92 100644 --- a/programs/benchmark-iostreams/main.cpp +++ b/programs/benchmark-iostreams/main.cpp @@ -26,7 +26,11 @@ Distributed under the Boost Software License, Version 1.0. #define REGIONSIZE (100 * 1024 * 1024) #include "../../include/afio/afio.hpp" +#if __has_include("quickcpplib/include/algorithm/small_prng.hpp") +#include "quickcpplib/include/algorithm/small_prng.hpp" +#else #include "../../include/afio/v2.0/quickcpplib/include/algorithm/small_prng.hpp" +#endif #include #include @@ -142,11 +146,16 @@ template inline void run_test(const char *csv, off_t max_extent, F &&f int main() { - nanoclock(); { - std::ofstream testfile("testfile"); + auto th = afio::file({}, "testfile", afio::file_handle::mode::write, afio::file_handle::creation::if_needed).value(); std::vector buffer(REGIONSIZE, 'a'); - testfile.write(buffer.data(), buffer.size()); + th.write(0, {{(afio::byte *) buffer.data(), buffer.size()}}).value(); + th.barrier({}, true, true).value(); + } + { + auto begin = nanoclock(); + while(nanoclock() - begin < 1000000000ULL) + ; } #if 0 { @@ -184,11 +193,13 @@ int main() testfile.read(buffer, len); }); } +#endif { std::cout << "Testing latency of afio::file_handle ..." << std::endl; auto th = afio::file({}, "testfile").value(); run_test("file_handle.csv", REGIONSIZE, [&](unsigned offset, char *buffer, size_t len) { th.read(offset, {{(afio::byte *) buffer, len}}).value(); }); } +#if 1 { std::cout << "Testing latency of afio::mapped_file_handle ..." << std::endl; auto th = afio::mapped_file({}, "testfile").value(); -- cgit v1.2.3