Skip to content

Commit

Permalink
adding stricter warning level / removing erroneous tests / modernizin…
Browse files Browse the repository at this point in the history
…g a bit more
  • Loading branch information
cdacamar committed Apr 9, 2017
1 parent 8967739 commit bd09fc1
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 107 deletions.
6 changes: 3 additions & 3 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.1)
project(trie_benchmark)

include_directories(./tiny_benchmark/include)
include_directories(../)
include_directories(../include)

if (POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
Expand All @@ -14,8 +14,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(RELEASE_FLAGS "/GS /GL /W3 /Gy /Zi /O2 /MD")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
else()
set(DEBUG_FLAGS "-g -O0 -Wall -Werror -std=c++1z")
set(RELEASE_FLAGS "-O3 -Wall -Werror -std=c++1z")
set(DEBUG_FLAGS "-g -O0 -Wall -Wextra -Werror -std=c++1z")
set(RELEASE_FLAGS "-O3 -Wall -Wextra -Werror -std=c++1z")
endif()

set(CMAKE_CXX_FLAGS_DEBUG ${DEBUG_FLAGS})
Expand Down
13 changes: 6 additions & 7 deletions benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ SOFTWARE.
#include <type_traits>
#include <unordered_map>

#include <include/trie.h>

#include <tiny_benchmark.h>
#include <trie.h>

#define ELMS 1000000
#define ELM_COUNT_IMPL(count) " in " #count " elements"
Expand All @@ -56,20 +55,20 @@ int main() {

auto rnd_seed = d();
std::cout << "RND Seed: " << rnd_seed << '\n';
std::mt19937 gen(rnd_seed);
std::mt19937 gen{rnd_seed};

// generate random words for us to use to make benchmarks between the implementations fair
std::vector<std::string> random_words;
std::uniform_int_distribution<> dis(10, 100); // words between 10 and 100 chars in len (so some have to be on the heap)
std::uniform_int_distribution<> letter_dis(0, 25); // letters
std::uniform_int_distribution<> dis{10, 100}; // words between 10 and 100 chars in len (so some have to be on the heap)
std::uniform_int_distribution<> letter_dis{0, 25}; // letters
for (int i = 0; i != ELMS; ++i) {
random_words.emplace_back();

auto& word = random_words.back();
word.resize(dis(gen), 'a');

std::transform(std::begin(word), std::end(word), std::begin(word),
[&gen, &letter_dis](char c) ->char { return 'a' + static_cast<char>(letter_dis(gen)); });
[&gen, &letter_dis](char) ->char { return 'a' + static_cast<char>(letter_dis(gen)); });
}

SECTION("BENCHMARK [baseline (unsorted): std::vector]")
Expand Down Expand Up @@ -413,4 +412,4 @@ int main() {
tiny_bench::escape(t.exists(long_word));
});
}
}
}
Loading

0 comments on commit bd09fc1

Please sign in to comment.