/******************************************************************************* * tests/container/btree_speedtest.cpp * * Part of tlx - http://panthema.net/tlx * * Copyright (C) 2008-2018 Timo Bingmann * * All rights reserved. Published under the Boost Software License, Version 1.0 ******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // *** Settings //! starting number of items to insert const size_t min_items = 125; //! maximum number of items to insert const size_t max_items = 1024000 * 64; //! random seed const int seed = 34234235; //! Traits used for the speed tests, BTREE_DEBUG is not defined. template struct btree_traits_speed : tlx::btree_default_traits { static const bool self_verify = false; static const bool debug = false; static const int leaf_slots = InnerSlots; static const int inner_slots = LeafSlots; static const size_t binsearch_threshold = 256 * 1024 * 1024; // never }; // ----------------------------------------------------------------------------- //! Test a generic set type with insertions template class Test_Set_Insert { public: Test_Set_Insert(size_t) { } static const char * op() { return "set_insert"; } void run(size_t items) { SetType set; std::default_random_engine rng(seed); for (size_t i = 0; i < items; i++) set.insert(rng()); die_unless(set.size() == items); } }; //! Test a generic set type with insert, find and delete sequences template class Test_Set_InsertFindDelete { public: Test_Set_InsertFindDelete(size_t) { } static const char * op() { return "set_insert_find_delete"; } void run(size_t items) { SetType set; std::default_random_engine rng(seed); for (size_t i = 0; i < items; i++) set.insert(rng()); die_unless(set.size() == items); rng.seed(seed); for (size_t i = 0; i < items; i++) set.find(rng()); rng.seed(seed); for (size_t i = 0; i < items; i++) set.erase(set.find(rng())); die_unless(set.empty()); } }; //! Test a generic set type with insert, find and delete sequences template class Test_Set_Find { public: SetType set; static const char * op() { return "set_find"; } Test_Set_Find(size_t items) { std::default_random_engine rng(seed); for (size_t i = 0; i < items; i++) set.insert(rng()); die_unless(set.size() == items); } void run(size_t items) { std::default_random_engine rng(seed); for (size_t i = 0; i < items; i++) set.find(rng()); } }; //! Construct different set types for a generic test class template