diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | CONTRIBUTORS | 4 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | README.md | 44 | ||||
-rw-r--r-- | cmake/CXXFeatureCheck.cmake | 4 | ||||
-rw-r--r-- | cmake/GoogleTest.cmake | 2 | ||||
-rw-r--r-- | src/sysinfo.cc | 9 | ||||
-rw-r--r-- | test/string_util_gtest.cc | 7 |
8 files changed, 63 insertions, 14 deletions
@@ -14,6 +14,7 @@ Andriy Berestovskyy <berestovskyy@gmail.com> Arne Beer <arne@twobeer.de> Carto Christopher Seymour <chris.j.seymour@hotmail.com> +Colin Braley <braley.colin@gmail.com> Daniel Harvey <danielharvey458@gmail.com> David Coeurjolly <david.coeurjolly@liris.cnrs.fr> Deniz Evrenci <denizevrenci@gmail.com> diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5be6dc4..6b64a00 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -29,6 +29,7 @@ Arne Beer <arne@twobeer.de> Billy Robert O'Neal III <billy.oneal@gmail.com> <bion@microsoft.com> Chris Kennelly <ckennelly@google.com> <ckennelly@ckennelly.com> Christopher Seymour <chris.j.seymour@hotmail.com> +Colin Braley <braley.colin@gmail.com> Cyrille Faucheux <cyrille.faucheux@gmail.com> Daniel Harvey <danielharvey458@gmail.com> David Coeurjolly <david.coeurjolly@liris.cnrs.fr> @@ -41,6 +42,7 @@ Eugene Zhuk <eugene.zhuk@gmail.com> Evgeny Safronov <division494@gmail.com> Federico Ficarelli <federico.ficarelli@gmail.com> Felix Homann <linuxaudio@showlabor.de> +Geoffrey Martin-Noble <gcmn@google.com> <gmngeoffrey@gmail.com> Hannes Hauswedell <h2@fsfe.org> Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com> Jern-Kuan Leong <jernkuan@gmail.com> @@ -49,8 +51,8 @@ Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com> John Millikin <jmillikin@stripe.com> Jussi Knuuttila <jussi.knuuttila@gmail.com> Kai Wolf <kai.wolf@gmail.com> -Kishan Kumar <kumar.kishan@outlook.com> Kaito Udagawa <umireon@gmail.com> +Kishan Kumar <kumar.kishan@outlook.com> Lei Xu <eddyxu@gmail.com> Matt Clarkson <mattyclarkson@gmail.com> Maxim Vafin <maxvafin@gmail.com> @@ -9,10 +9,10 @@ third_party { type: GIT value: "https://github.com/google/benchmark.git" } - version: "7ee72863fdb1ccb2af5a011250b56af3f49b7511" + version: "f4f5dba46bdbde0e95d736cca124025745bcd7b6" last_upgrade_date { year: 2019 - month: 9 - day: 6 + month: 10 + day: 7 } } @@ -52,6 +52,8 @@ The following minimum versions are required to build the library: * Visual Studio 14 2015 * Intel 2015 Update 1 +See [Platform-Specific Build Instructions](#platform-specific-build-instructions). + ## Installation This describes the installation process using cmake. As pre-requisites, you'll @@ -180,8 +182,8 @@ library will be under the build directory you created. ```bash # Example on linux after running the build steps above. Assumes the # `benchmark` and `build` directories are under the current directory. -$ g++ -std=c++11 -isystem benchmark/include -Lbuild/src -lpthread \ - -lbenchmark mybenchmark.cc -o mybenchmark +$ g++ mybenchmark.cc -std=c++11 -isystem benchmark/include \ + -Lbenchmark/build/src -lbenchmark -lpthread -o mybenchmark ``` Alternatively, link against the `benchmark_main` library and remove @@ -190,7 +192,9 @@ Alternatively, link against the `benchmark_main` library and remove The compiled executable will run all benchmarks by default. Pass the `--help` flag for option information or see the guide below. -### Platform-specific instructions +## Platform Specific Build Instructions + +### Building with GCC When the library is built using GCC it is necessary to link with the pthread library due to how GCC implements `std::thread`. Failing to link to pthread will @@ -200,8 +204,34 @@ can link to pthread by adding `-pthread` to your linker command. Note, you can also use `-lpthread`, but there are potential issues with ordering of command line parameters if you use that. -If you're running benchmarks on Windows, the shlwapi library (`-lshlwapi`) is -also required. +### Building with Visual Studio 2015 or 2017 + +The `shlwapi` library (`-lshlwapi`) is required to support a call to `CPUInfo` which reads the registry. Either add `shlwapi.lib` under `[ Configuration Properties > Linker > Input ]`, or use the following: + +``` +// Alternatively, can add libraries using linker options. +#ifdef _WIN32 +#pragma comment ( lib, "Shlwapi.lib" ) +#ifdef _DEBUG +#pragma comment ( lib, "benchmarkd.lib" ) +#else +#pragma comment ( lib, "benchmark.lib" ) +#endif +#endif +``` + +Can also use the graphical version of CMake: +* Open `CMake GUI`. +* Under `Where to build the binaries`, same path as source plus `build`. +* Under `CMAKE_INSTALL_PREFIX`, same path as source plus `install`. +* Click `Configure`, `Generate`, `Open Project`. +* If build fails, try deleting entire directory and starting again, or unticking options to build less. + +### Building with Intel 2015 Update 1 or Intel System Studio Update 4 + +See instructions for building with Visual Studio. Once built, right click on the solution and change the build to Intel. + +### Building on Solaris If you're running benchmarks on solaris, you'll want the kstat library linked in too (`-lkstat`). @@ -843,7 +873,7 @@ static void MyMain(int size) { static void BM_OpenMP(benchmark::State& state) { for (auto _ : state) - MyMain(state.range(0); + MyMain(state.range(0)); } // Measure the time spent by the main thread, use it to decide for how long to @@ -920,7 +950,7 @@ static void BM_ManualTiming(benchmark::State& state) { auto start = std::chrono::high_resolution_clock::now(); // Simulate some useful workload with a sleep std::this_thread::sleep_for(sleep_duration); - auto end = std::chrono::high_resolution_clock::now(); + auto end = std::chrono::high_resolution_clock::now(); auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>( diff --git a/cmake/CXXFeatureCheck.cmake b/cmake/CXXFeatureCheck.cmake index 99b56dd..059d510 100644 --- a/cmake/CXXFeatureCheck.cmake +++ b/cmake/CXXFeatureCheck.cmake @@ -37,9 +37,9 @@ function(cxx_feature_check FILE) if(COMPILE_${FEATURE}) message(WARNING "If you see build failures due to cross compilation, try setting HAVE_${VAR} to 0") - set(RUN_${FEATURE} 0) + set(RUN_${FEATURE} 0 CACHE INTERNAL "") else() - set(RUN_${FEATURE} 1) + set(RUN_${FEATURE} 1 CACHE INTERNAL "") endif() else() message(STATUS "Performing Test ${FEATURE}") diff --git a/cmake/GoogleTest.cmake b/cmake/GoogleTest.cmake index fb7c6be..dd611fc 100644 --- a/cmake/GoogleTest.cmake +++ b/cmake/GoogleTest.cmake @@ -2,7 +2,7 @@ set(GOOGLETEST_PREFIX "${benchmark_BINARY_DIR}/third_party/googletest") configure_file(${benchmark_SOURCE_DIR}/cmake/GoogleTest.cmake.in ${GOOGLETEST_PREFIX}/CMakeLists.txt @ONLY) -set(GOOGLETEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/googletest") # Mind the quotes +set(GOOGLETEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/googletest" CACHE PATH "") # Mind the quotes execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DALLOW_DOWNLOADING_GOOGLETEST=${BENCHMARK_DOWNLOAD_DEPENDENCIES} -DGOOGLETEST_PATH:PATH=${GOOGLETEST_PATH} . RESULT_VARIABLE result diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 2812647..b5f99c7 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -429,11 +429,20 @@ std::string GetSystemName() { #endif return str; #else // defined(BENCHMARK_OS_WINDOWS) +#ifndef HOST_NAME_MAX #ifdef BENCHMARK_HAS_SYSCTL // BSD/Mac Doesnt have HOST_NAME_MAX defined #define HOST_NAME_MAX 64 +#elif defined(BENCHMARK_OS_NACL) +#define HOST_NAME_MAX 64 #elif defined(BENCHMARK_OS_QNX) #define HOST_NAME_MAX 154 +#elif defined(BENCHMARK_OS_RTEMS) +#define HOST_NAME_MAX 256 +#else +#warning "HOST_NAME_MAX not defined. using 64" +#define HOST_NAME_MAX 64 #endif +#endif // def HOST_NAME_MAX char hostname[HOST_NAME_MAX]; int retVal = gethostname(hostname, HOST_NAME_MAX); if (retVal != 0) return std::string(""); diff --git a/test/string_util_gtest.cc b/test/string_util_gtest.cc index 2c5d073..01bf155 100644 --- a/test/string_util_gtest.cc +++ b/test/string_util_gtest.cc @@ -3,6 +3,7 @@ //===---------------------------------------------------------------------===// #include "../src/string_util.h" +#include "../src/internal_macros.h" #include "gtest/gtest.h" namespace { @@ -60,9 +61,11 @@ TEST(StringUtilTest, stoul) { EXPECT_EQ(0xBEEFul, benchmark::stoul("BEEF", &pos, 16)); EXPECT_EQ(4ul, pos); } +#ifndef BENCHMARK_HAS_NO_EXCEPTIONS { ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument); } +#endif } TEST(StringUtilTest, stoi) { @@ -106,9 +109,11 @@ TEST(StringUtilTest, stoi) { EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16)); EXPECT_EQ(4ul, pos); } +#ifndef BENCHMARK_HAS_NO_EXCEPTIONS { ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument); } +#endif } TEST(StringUtilTest, stod) { @@ -138,9 +143,11 @@ TEST(StringUtilTest, stod) { EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos)); EXPECT_EQ(8ul, pos); } +#ifndef BENCHMARK_HAS_NO_EXCEPTIONS { ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument); } +#endif } } // end namespace |