From 026d38e8fb58c114b7cabcdb5e00650368dfb681 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 31 Oct 2016 02:46:25 +0000 Subject: [PATCH] Optimize filesystem::path by providing weaker exception guarantees. path uses string::append to construct, append, and concatenate paths. Unfortunatly string::append has a strong exception safety guaranteed and if it can't prove that the iterator operations don't throw then it will allocate a temporary string copy to append to. However this extra allocation and copy is very undesirable for path which doesn't have the same exception guarantees. To work around this this patch adds string::__append_forward_unsafe which exposes the std::string::append interface for forward iterators without enforcing that the iterator is noexcept. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285532 91177308-0d34-0410-b5e6-96231b3b80d8 --- benchmarks/CMakeLists.txt | 1 + benchmarks/filesystem.bench.cpp | 34 ++++++++++++++++++++++++++ include/experimental/filesystem | 14 +++++++++-- include/string | 42 ++++++++++++++------------------- 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 253fbd684..a4105be08 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -69,6 +69,7 @@ set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) set(BENCHMARK_TEST_COMPILE_FLAGS -std=c++14 -O2 -I${BENCHMARK_LIBCXX_INSTALL}/include + -I${LIBCXX_SOURCE_DIR}/test/support ) set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS -nostdinc++ diff --git a/benchmarks/filesystem.bench.cpp b/benchmarks/filesystem.bench.cpp index 2cea3f69c..f7949a163 100644 --- a/benchmarks/filesystem.bench.cpp +++ b/benchmarks/filesystem.bench.cpp @@ -2,6 +2,7 @@ #include "benchmark/benchmark_api.h" #include "GenerateInput.hpp" +#include "test_iterators.h" namespace fs = std::experimental::filesystem; @@ -41,6 +42,39 @@ void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) { BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string, getRandomStringInputs)->Arg(TestNumInputs); + +template