From bfaee1a65ea9e9fd7ff702a73377e5c2df6cc348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 02:01:33 +0300 Subject: [PATCH 1/6] =?UTF-8?q?refs=20#118=20=D0=97=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=80=D1=8B=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D1=87=D0=BD=D1=8B=D1=85=20=D0=B2=D0=B5=D1=89=D0=B5=D0=B9=20?= =?UTF-8?q?=E2=80=94=20=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D1=83=D1=8E=20=D0=B4=D0=B8?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/CMakeLists.txt | 5 +---- benchmark/burst/CMakeLists.txt | 4 ++++ benchmark/{ => burst}/algorithm/CMakeLists.txt | 0 benchmark/{ => burst}/algorithm/galloping_lower_bound.cpp | 0 .../{ => burst}/algorithm/integer_sort_comparison.py.in | 0 benchmark/{ => burst}/algorithm/radix_sort.cpp | 0 benchmark/{ => burst}/container/CMakeLists.txt | 0 benchmark/{ => burst}/container/dynamic_tuple.cpp | 0 .../{ => burst}/container/dynamic_tuple_benchmark.py.in | 0 benchmark/{ => burst}/container/k_ary_search_set.cpp | 0 benchmark/{ => burst}/integer/CMakeLists.txt | 0 benchmark/{ => burst}/integer/divceil.cpp | 0 benchmark/{ => burst}/iterator/CMakeLists.txt | 0 benchmark/{ => burst}/iterator/intersect_iterator.cpp | 0 benchmark/{ => burst}/iterator/merge_iterator.cpp | 0 benchmark/{ => burst}/iterator/subset_iterator.cpp | 0 16 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 benchmark/burst/CMakeLists.txt rename benchmark/{ => burst}/algorithm/CMakeLists.txt (100%) rename benchmark/{ => burst}/algorithm/galloping_lower_bound.cpp (100%) rename benchmark/{ => burst}/algorithm/integer_sort_comparison.py.in (100%) rename benchmark/{ => burst}/algorithm/radix_sort.cpp (100%) rename benchmark/{ => burst}/container/CMakeLists.txt (100%) rename benchmark/{ => burst}/container/dynamic_tuple.cpp (100%) rename benchmark/{ => burst}/container/dynamic_tuple_benchmark.py.in (100%) rename benchmark/{ => burst}/container/k_ary_search_set.cpp (100%) rename benchmark/{ => burst}/integer/CMakeLists.txt (100%) rename benchmark/{ => burst}/integer/divceil.cpp (100%) rename benchmark/{ => burst}/iterator/CMakeLists.txt (100%) rename benchmark/{ => burst}/iterator/intersect_iterator.cpp (100%) rename benchmark/{ => burst}/iterator/merge_iterator.cpp (100%) rename benchmark/{ => burst}/iterator/subset_iterator.cpp (100%) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index df39e4a5..796ae700 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -6,7 +6,4 @@ target_include_directories(benchIO INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_executable(rangegen range_generator.cpp) target_link_libraries(rangegen PRIVATE Burst::burst benchIO Boost::program_options) -add_subdirectory(algorithm) -add_subdirectory(container) -add_subdirectory(integer) -add_subdirectory(iterator) +add_subdirectory(burst) diff --git a/benchmark/burst/CMakeLists.txt b/benchmark/burst/CMakeLists.txt new file mode 100644 index 00000000..25a547f4 --- /dev/null +++ b/benchmark/burst/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(algorithm) +add_subdirectory(container) +add_subdirectory(integer) +add_subdirectory(iterator) diff --git a/benchmark/algorithm/CMakeLists.txt b/benchmark/burst/algorithm/CMakeLists.txt similarity index 100% rename from benchmark/algorithm/CMakeLists.txt rename to benchmark/burst/algorithm/CMakeLists.txt diff --git a/benchmark/algorithm/galloping_lower_bound.cpp b/benchmark/burst/algorithm/galloping_lower_bound.cpp similarity index 100% rename from benchmark/algorithm/galloping_lower_bound.cpp rename to benchmark/burst/algorithm/galloping_lower_bound.cpp diff --git a/benchmark/algorithm/integer_sort_comparison.py.in b/benchmark/burst/algorithm/integer_sort_comparison.py.in similarity index 100% rename from benchmark/algorithm/integer_sort_comparison.py.in rename to benchmark/burst/algorithm/integer_sort_comparison.py.in diff --git a/benchmark/algorithm/radix_sort.cpp b/benchmark/burst/algorithm/radix_sort.cpp similarity index 100% rename from benchmark/algorithm/radix_sort.cpp rename to benchmark/burst/algorithm/radix_sort.cpp diff --git a/benchmark/container/CMakeLists.txt b/benchmark/burst/container/CMakeLists.txt similarity index 100% rename from benchmark/container/CMakeLists.txt rename to benchmark/burst/container/CMakeLists.txt diff --git a/benchmark/container/dynamic_tuple.cpp b/benchmark/burst/container/dynamic_tuple.cpp similarity index 100% rename from benchmark/container/dynamic_tuple.cpp rename to benchmark/burst/container/dynamic_tuple.cpp diff --git a/benchmark/container/dynamic_tuple_benchmark.py.in b/benchmark/burst/container/dynamic_tuple_benchmark.py.in similarity index 100% rename from benchmark/container/dynamic_tuple_benchmark.py.in rename to benchmark/burst/container/dynamic_tuple_benchmark.py.in diff --git a/benchmark/container/k_ary_search_set.cpp b/benchmark/burst/container/k_ary_search_set.cpp similarity index 100% rename from benchmark/container/k_ary_search_set.cpp rename to benchmark/burst/container/k_ary_search_set.cpp diff --git a/benchmark/integer/CMakeLists.txt b/benchmark/burst/integer/CMakeLists.txt similarity index 100% rename from benchmark/integer/CMakeLists.txt rename to benchmark/burst/integer/CMakeLists.txt diff --git a/benchmark/integer/divceil.cpp b/benchmark/burst/integer/divceil.cpp similarity index 100% rename from benchmark/integer/divceil.cpp rename to benchmark/burst/integer/divceil.cpp diff --git a/benchmark/iterator/CMakeLists.txt b/benchmark/burst/iterator/CMakeLists.txt similarity index 100% rename from benchmark/iterator/CMakeLists.txt rename to benchmark/burst/iterator/CMakeLists.txt diff --git a/benchmark/iterator/intersect_iterator.cpp b/benchmark/burst/iterator/intersect_iterator.cpp similarity index 100% rename from benchmark/iterator/intersect_iterator.cpp rename to benchmark/burst/iterator/intersect_iterator.cpp diff --git a/benchmark/iterator/merge_iterator.cpp b/benchmark/burst/iterator/merge_iterator.cpp similarity index 100% rename from benchmark/iterator/merge_iterator.cpp rename to benchmark/burst/iterator/merge_iterator.cpp diff --git a/benchmark/iterator/subset_iterator.cpp b/benchmark/burst/iterator/subset_iterator.cpp similarity index 100% rename from benchmark/iterator/subset_iterator.cpp rename to benchmark/burst/iterator/subset_iterator.cpp From 580d801a8a68738a87ae153f047338fa8535d71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 02:23:21 +0300 Subject: [PATCH 2/6] =?UTF-8?q?refs=20#118=20=D0=94=D0=B5=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BF=D0=BE=D0=B7=D0=B8=D1=86=D0=B8=D1=8F=20=D0=B1=D0=B8?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA=D0=B8=20=D0=B2=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0-=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/CMakeLists.txt | 2 +- .../burst/algorithm/galloping_lower_bound.cpp | 3 +- benchmark/burst/algorithm/radix_sort.cpp | 3 +- .../burst/container/k_ary_search_set.cpp | 3 +- benchmark/burst/integer/divceil.cpp | 3 +- .../burst/iterator/intersect_iterator.cpp | 3 +- benchmark/burst/iterator/merge_iterator.cpp | 3 +- benchmark/burst/iterator/subset_iterator.cpp | 3 +- benchmark/include/utility/io/read.hpp | 29 ++++++++++ benchmark/include/utility/io/read_many.hpp | 20 +++++++ benchmark/include/utility/io/write.hpp | 25 ++++++++ benchmark/io.hpp | 57 ------------------- benchmark/range_generator.cpp | 2 +- 13 files changed, 90 insertions(+), 66 deletions(-) create mode 100644 benchmark/include/utility/io/read.hpp create mode 100644 benchmark/include/utility/io/read_many.hpp create mode 100644 benchmark/include/utility/io/write.hpp delete mode 100644 benchmark/io.hpp diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 796ae700..d977355c 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -1,7 +1,7 @@ find_package(Boost 1.62.0 COMPONENTS program_options REQUIRED) add_library(benchIO INTERFACE) -target_include_directories(benchIO INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(benchIO INTERFACE include) add_executable(rangegen range_generator.cpp) target_link_libraries(rangegen PRIVATE Burst::burst benchIO Boost::program_options) diff --git a/benchmark/burst/algorithm/galloping_lower_bound.cpp b/benchmark/burst/algorithm/galloping_lower_bound.cpp index 8c5e75f7..f49de7af 100644 --- a/benchmark/burst/algorithm/galloping_lower_bound.cpp +++ b/benchmark/burst/algorithm/galloping_lower_bound.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include diff --git a/benchmark/burst/algorithm/radix_sort.cpp b/benchmark/burst/algorithm/radix_sort.cpp index 097beb12..6b42d4e6 100644 --- a/benchmark/burst/algorithm/radix_sort.cpp +++ b/benchmark/burst/algorithm/radix_sort.cpp @@ -1,6 +1,7 @@ +#include + #include #include -#include #include #include diff --git a/benchmark/burst/container/k_ary_search_set.cpp b/benchmark/burst/container/k_ary_search_set.cpp index e70b971f..7856da22 100644 --- a/benchmark/burst/container/k_ary_search_set.cpp +++ b/benchmark/burst/container/k_ary_search_set.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include #include diff --git a/benchmark/burst/integer/divceil.cpp b/benchmark/burst/integer/divceil.cpp index 3da10691..8e035eee 100644 --- a/benchmark/burst/integer/divceil.cpp +++ b/benchmark/burst/integer/divceil.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include #include diff --git a/benchmark/burst/iterator/intersect_iterator.cpp b/benchmark/burst/iterator/intersect_iterator.cpp index 4ea7daba..e037bc10 100644 --- a/benchmark/burst/iterator/intersect_iterator.cpp +++ b/benchmark/burst/iterator/intersect_iterator.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include #include diff --git a/benchmark/burst/iterator/merge_iterator.cpp b/benchmark/burst/iterator/merge_iterator.cpp index 89bfce18..caac19cb 100644 --- a/benchmark/burst/iterator/merge_iterator.cpp +++ b/benchmark/burst/iterator/merge_iterator.cpp @@ -1,6 +1,7 @@ +#include + #include #include -#include #include #include diff --git a/benchmark/burst/iterator/subset_iterator.cpp b/benchmark/burst/iterator/subset_iterator.cpp index 3568933b..f269f09d 100644 --- a/benchmark/burst/iterator/subset_iterator.cpp +++ b/benchmark/burst/iterator/subset_iterator.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include #include diff --git a/benchmark/include/utility/io/read.hpp b/benchmark/include/utility/io/read.hpp new file mode 100644 index 00000000..9032d4a0 --- /dev/null +++ b/benchmark/include/utility/io/read.hpp @@ -0,0 +1,29 @@ +#ifndef BURST_BENCHMARK_UTILITY_IO_READ_HPP +#define BURST_BENCHMARK_UTILITY_IO_READ_HPP + +#include + +#include +#include +#include + +template +std::istream & read (std::istream & stream, Container & values) +{ + auto size = std::size_t{}; + if (burst::trivial_read(stream, size)) + { + values.resize(size); + + for (auto & value: values) + { + auto n = std::int64_t{}; + burst::trivial_read(stream, n); + value = static_cast(n); + } + } + + return stream; +} + +#endif // BURST_BENCHMARK_UTILITY_IO_READ_HPP diff --git a/benchmark/include/utility/io/read_many.hpp b/benchmark/include/utility/io/read_many.hpp new file mode 100644 index 00000000..c8c3a1b3 --- /dev/null +++ b/benchmark/include/utility/io/read_many.hpp @@ -0,0 +1,20 @@ +#ifndef BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP +#define BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP + +#include + +#include + +template +std::istream & read_many (std::istream & stream, Container & containers) +{ + auto container = typename Container::value_type{}; + while (read(stream, container)) + { + containers.push_back(container); + } + + return stream; +} + +#endif // BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP diff --git a/benchmark/include/utility/io/write.hpp b/benchmark/include/utility/io/write.hpp new file mode 100644 index 00000000..40c87a54 --- /dev/null +++ b/benchmark/include/utility/io/write.hpp @@ -0,0 +1,25 @@ +#ifndef BURST_BENCHMARK_UTILITY_IO_WRITE_HPP +#define BURST_BENCHMARK_UTILITY_IO_WRITE_HPP + +#include +#include + +#include + +#include +#include +#include + +template +std::ostream & write (std::ostream & stream, const Container & values) +{ + burst::trivial_write(stream, static_cast(values.size())); + boost::transform(values, burst::make_binary_ostream_iterator(stream), + [] (std::int64_t v) {return v;}); + // Элементы контейнера должны уметь неявно (то есть без потерь) преобразовываться к + // std::int64_t, т.к. это "официальный" формат обмена числами между приложениями. + + return stream; +} + +#endif // BURST_BENCHMARK_UTILITY_IO_WRITE_HPP diff --git a/benchmark/io.hpp b/benchmark/io.hpp deleted file mode 100644 index bf50335e..00000000 --- a/benchmark/io.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef BURST_BENCHMARK_IO_HPP -#define BURST_BENCHMARK_IO_HPP - -#include -#include -#include - -#include - -#include -#include -#include - -template -std::ostream & write (std::ostream & stream, const Container & values) -{ - burst::trivial_write(stream, static_cast(values.size())); - boost::transform(values, burst::make_binary_ostream_iterator(stream), - [] (std::int64_t v) {return v;}); - // Элементы контейнера должны уметь неявно (то есть без потерь) преобразовываться к - // std::int64_t, т.к. это "официальный" формат обмена числами между приложениями. - - return stream; -} - -template -std::istream & read (std::istream & stream, Container & values) -{ - auto size = std::size_t{}; - if (burst::trivial_read(stream, size)) - { - values.resize(size); - - for (auto & value: values) - { - auto n = std::int64_t{}; - burst::trivial_read(stream, n); - value = static_cast(n); - } - } - - return stream; -} - -template -std::istream & read_many (std::istream & stream, Container & containers) -{ - auto container = typename Container::value_type{}; - while (read(stream, container)) - { - containers.push_back(container); - } - - return stream; -} - -#endif // BURST_BENCHMARK_IO_HPP diff --git a/benchmark/range_generator.cpp b/benchmark/range_generator.cpp index 9ca7fbf5..c41864bb 100644 --- a/benchmark/range_generator.cpp +++ b/benchmark/range_generator.cpp @@ -1,4 +1,4 @@ -#include +#include #include From df55df6322992faf0c1983e5332fdee0e0a58a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 02:28:26 +0300 Subject: [PATCH 3/6] =?UTF-8?q?refs=20#118=20=D0=9F=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D1=81=D1=82=D0=B2=D0=BE=20=D0=B8=D0=BC?= =?UTF-8?q?=D1=91=D0=BD=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BB=D1=83=D0=B6?= =?UTF-8?q?=D0=B5=D0=B1=D0=BD=D1=8B=D1=85=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../burst/algorithm/galloping_lower_bound.cpp | 2 +- benchmark/burst/algorithm/radix_sort.cpp | 2 +- .../burst/container/k_ary_search_set.cpp | 2 +- benchmark/burst/integer/divceil.cpp | 2 +- .../burst/iterator/intersect_iterator.cpp | 2 +- benchmark/burst/iterator/merge_iterator.cpp | 2 +- benchmark/burst/iterator/subset_iterator.cpp | 2 +- benchmark/include/utility/io/read.hpp | 29 ++++++++++--------- benchmark/include/utility/io/read_many.hpp | 19 +++++++----- benchmark/include/utility/io/write.hpp | 21 ++++++++------ benchmark/range_generator.cpp | 2 +- 11 files changed, 47 insertions(+), 38 deletions(-) diff --git a/benchmark/burst/algorithm/galloping_lower_bound.cpp b/benchmark/burst/algorithm/galloping_lower_bound.cpp index f49de7af..58be936b 100644 --- a/benchmark/burst/algorithm/galloping_lower_bound.cpp +++ b/benchmark/burst/algorithm/galloping_lower_bound.cpp @@ -55,7 +55,7 @@ int main (int argc, const char * argv[]) else { std::vector numbers; - read(std::cin, numbers); + utility::read(std::cin, numbers); std::size_t attempts = vm["attempts"].as(); test(numbers, attempts, [] (auto f, auto l, const auto & v) {return burst::galloping_lower_bound(f, l, v);}, "gallop"); diff --git a/benchmark/burst/algorithm/radix_sort.cpp b/benchmark/burst/algorithm/radix_sort.cpp index 6b42d4e6..0cb81f63 100644 --- a/benchmark/burst/algorithm/radix_sort.cpp +++ b/benchmark/burst/algorithm/radix_sort.cpp @@ -44,7 +44,7 @@ template void test_all (std::size_t attempts, UnaryFunction prepare) { std::vector numbers; - read(std::cin, numbers); + utility::read(std::cin, numbers); std::vector buffer(numbers.size()); diff --git a/benchmark/burst/container/k_ary_search_set.cpp b/benchmark/burst/container/k_ary_search_set.cpp index 7856da22..4cd655ed 100644 --- a/benchmark/burst/container/k_ary_search_set.cpp +++ b/benchmark/burst/container/k_ary_search_set.cpp @@ -81,7 +81,7 @@ void test (const Container & arities, std::size_t attempts) { using integer_type = std::int64_t; std::vector numbers; - read(std::cin, numbers); + utility::read(std::cin, numbers); std::sort(numbers.begin(), numbers.end()); numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end()); diff --git a/benchmark/burst/integer/divceil.cpp b/benchmark/burst/integer/divceil.cpp index 8e035eee..0758345f 100644 --- a/benchmark/burst/integer/divceil.cpp +++ b/benchmark/burst/integer/divceil.cpp @@ -45,7 +45,7 @@ template void test_all (std::int64_t divisor, std::size_t attempt_count) { std::vector values; - read(std::cin, values); + utility::read(std::cin, values); test_divceil(values, static_cast(divisor), attempt_count); } diff --git a/benchmark/burst/iterator/intersect_iterator.cpp b/benchmark/burst/iterator/intersect_iterator.cpp index e037bc10..8503eb11 100644 --- a/benchmark/burst/iterator/intersect_iterator.cpp +++ b/benchmark/burst/iterator/intersect_iterator.cpp @@ -54,7 +54,7 @@ void test_std_intersect (const Container & values) int main () { std::vector> values; - read_many(std::cin, values); + utility::read_many(std::cin, values); test_std_intersect(values); test_on_the_fly_intersect(values); diff --git a/benchmark/burst/iterator/merge_iterator.cpp b/benchmark/burst/iterator/merge_iterator.cpp index caac19cb..014cc266 100644 --- a/benchmark/burst/iterator/merge_iterator.cpp +++ b/benchmark/burst/iterator/merge_iterator.cpp @@ -86,7 +86,7 @@ void test_std_merge (const Container & values) int main () { std::vector> values; - read_many(std::cin, values); + utility::read_many(std::cin, values); test_merge_by_sorting(values); test_std_merge(values); diff --git a/benchmark/burst/iterator/subset_iterator.cpp b/benchmark/burst/iterator/subset_iterator.cpp index f269f09d..b911ae85 100644 --- a/benchmark/burst/iterator/subset_iterator.cpp +++ b/benchmark/burst/iterator/subset_iterator.cpp @@ -29,7 +29,7 @@ void test (const Container & numbers) int main () { std::vector numbers; - read(std::cin, numbers); + utility::read(std::cin, numbers); test(numbers); } diff --git a/benchmark/include/utility/io/read.hpp b/benchmark/include/utility/io/read.hpp index 9032d4a0..d7605b98 100644 --- a/benchmark/include/utility/io/read.hpp +++ b/benchmark/include/utility/io/read.hpp @@ -7,23 +7,26 @@ #include #include -template -std::istream & read (std::istream & stream, Container & values) +namespace utility { - auto size = std::size_t{}; - if (burst::trivial_read(stream, size)) + template + std::istream & read (std::istream & stream, Container & values) { - values.resize(size); - - for (auto & value: values) + auto size = std::size_t{}; + if (burst::trivial_read(stream, size)) { - auto n = std::int64_t{}; - burst::trivial_read(stream, n); - value = static_cast(n); + values.resize(size); + + for (auto & value: values) + { + auto n = std::int64_t{}; + burst::trivial_read(stream, n); + value = static_cast(n); + } } - } - return stream; -} + return stream; + } +} // namespace utility #endif // BURST_BENCHMARK_UTILITY_IO_READ_HPP diff --git a/benchmark/include/utility/io/read_many.hpp b/benchmark/include/utility/io/read_many.hpp index c8c3a1b3..d5eb5ad6 100644 --- a/benchmark/include/utility/io/read_many.hpp +++ b/benchmark/include/utility/io/read_many.hpp @@ -5,16 +5,19 @@ #include -template -std::istream & read_many (std::istream & stream, Container & containers) +namespace utility { - auto container = typename Container::value_type{}; - while (read(stream, container)) + template + std::istream & read_many (std::istream & stream, Container & containers) { - containers.push_back(container); - } + auto container = typename Container::value_type{}; + while (read(stream, container)) + { + containers.push_back(container); + } - return stream; -} + return stream; + } +} // namespace utility #endif // BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP diff --git a/benchmark/include/utility/io/write.hpp b/benchmark/include/utility/io/write.hpp index 40c87a54..ca32d822 100644 --- a/benchmark/include/utility/io/write.hpp +++ b/benchmark/include/utility/io/write.hpp @@ -10,16 +10,19 @@ #include #include -template -std::ostream & write (std::ostream & stream, const Container & values) +namespace utility { - burst::trivial_write(stream, static_cast(values.size())); - boost::transform(values, burst::make_binary_ostream_iterator(stream), - [] (std::int64_t v) {return v;}); - // Элементы контейнера должны уметь неявно (то есть без потерь) преобразовываться к - // std::int64_t, т.к. это "официальный" формат обмена числами между приложениями. + template + std::ostream & write (std::ostream & stream, const Container & values) + { + burst::trivial_write(stream, static_cast(values.size())); + boost::transform(values, burst::make_binary_ostream_iterator(stream), + [] (std::int64_t v) {return v;}); + // Элементы контейнера должны уметь неявно (то есть без потерь) преобразовываться к + // std::int64_t, т.к. это "официальный" формат обмена числами между приложениями. - return stream; -} + return stream; + } +} // namespace utility #endif // BURST_BENCHMARK_UTILITY_IO_WRITE_HPP diff --git a/benchmark/range_generator.cpp b/benchmark/range_generator.cpp index c41864bb..8e65a421 100644 --- a/benchmark/range_generator.cpp +++ b/benchmark/range_generator.cpp @@ -48,7 +48,7 @@ void } } - write(std::cout, range); + utility::write(std::cout, range); } } From d2e28a1132ac14a69a9c738705dbb665e43e33b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 02:42:27 +0300 Subject: [PATCH 4/6] =?UTF-8?q?refs=20#118=20=D0=A1=D0=BB=D1=83=D0=B6?= =?UTF-8?q?=D0=B5=D0=B1=D0=BD=D0=B0=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=BC=D0=B0=20=D1=83=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=83=D1=8E=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/CMakeLists.txt | 4 +--- benchmark/burst/algorithm/integer_sort_comparison.py.in | 2 +- benchmark/src/CMakeLists.txt | 2 ++ benchmark/{ => src}/range_generator.cpp | 0 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 benchmark/src/CMakeLists.txt rename benchmark/{ => src}/range_generator.cpp (100%) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index d977355c..79a78e7b 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -3,7 +3,5 @@ find_package(Boost 1.62.0 COMPONENTS program_options REQUIRED) add_library(benchIO INTERFACE) target_include_directories(benchIO INTERFACE include) -add_executable(rangegen range_generator.cpp) -target_link_libraries(rangegen PRIVATE Burst::burst benchIO Boost::program_options) - add_subdirectory(burst) +add_subdirectory(src) diff --git a/benchmark/burst/algorithm/integer_sort_comparison.py.in b/benchmark/burst/algorithm/integer_sort_comparison.py.in index b34842a7..56d73567 100755 --- a/benchmark/burst/algorithm/integer_sort_comparison.py.in +++ b/benchmark/burst/algorithm/integer_sort_comparison.py.in @@ -11,7 +11,7 @@ def measure (lengths, max_attempts, integer_type, prepare): measurements = {} command_template =\ - ("@CMAKE_BINARY_DIR@/benchmark/rangegen " + ("@CMAKE_BINARY_DIR@/benchmark/src/rangegen " "--count=1 " "--length={} | " "@CMAKE_BINARY_DIR@/benchmark/algorithm/radix " diff --git a/benchmark/src/CMakeLists.txt b/benchmark/src/CMakeLists.txt new file mode 100644 index 00000000..4a84071a --- /dev/null +++ b/benchmark/src/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(rangegen range_generator.cpp) +target_link_libraries(rangegen PRIVATE Burst::burst benchIO Boost::program_options) diff --git a/benchmark/range_generator.cpp b/benchmark/src/range_generator.cpp similarity index 100% rename from benchmark/range_generator.cpp rename to benchmark/src/range_generator.cpp From 5664363d5ce8ae493e505bc0c800f3493a93e034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 02:58:39 +0300 Subject: [PATCH 5/6] =?UTF-8?q?refs=20#118=20=D0=93=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D0=B9=20=E2=80=94=20=D0=B2=20=D0=B8=D0=BD?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/include/utility/io/generate.hpp | 59 +++++++++++++++++++++++ benchmark/src/range_generator.cpp | 52 ++------------------ 2 files changed, 63 insertions(+), 48 deletions(-) create mode 100644 benchmark/include/utility/io/generate.hpp diff --git a/benchmark/include/utility/io/generate.hpp b/benchmark/include/utility/io/generate.hpp new file mode 100644 index 00000000..22dd6927 --- /dev/null +++ b/benchmark/include/utility/io/generate.hpp @@ -0,0 +1,59 @@ +#ifndef BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP +#define BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace utility +{ + void + generate + ( + std::size_t range_count, + std::size_t range_length, + std::int64_t min, + std::int64_t max, + bool seed, + bool sort, + bool descending + ) + { + auto seed_value = seed + ? static_cast + ( + std::chrono::system_clock::now().time_since_epoch().count() + ) + : 0; + std::default_random_engine engine(seed_value); + std::uniform_int_distribution uniform(min, max); + + std::vector range(range_length); + for (std::size_t i = 0; i < range_count; ++i) + { + std::generate(range.begin(), range.end(), [&] () { return uniform(engine); }); + if (sort) + { + if (descending) + { + std::sort(range.begin(), range.end(), std::greater<>{}); + } + else + { + std::sort(range.begin(), range.end()); + } + } + + write(std::cout, range); + } + } +} // namespace utility + +#endif // BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP diff --git a/benchmark/src/range_generator.cpp b/benchmark/src/range_generator.cpp index 8e65a421..b440f523 100644 --- a/benchmark/src/range_generator.cpp +++ b/benchmark/src/range_generator.cpp @@ -1,56 +1,12 @@ -#include +#include #include -#include -#include +#include #include #include -#include #include -#include -#include - -void - generate - ( - std::size_t range_count, - std::size_t range_length, - std::int64_t min, - std::int64_t max, - bool seed, - bool sort, - bool descending - ) -{ - auto seed_value = seed - ? static_cast - ( - std::chrono::system_clock::now().time_since_epoch().count() - ) - : 0; - std::default_random_engine engine(seed_value); - std::uniform_int_distribution uniform(min, max); - - std::vector range(range_length); - for (std::size_t i = 0; i < range_count; ++i) - { - std::generate(range.begin(), range.end(), [&] () { return uniform(engine); }); - if (sort) - { - if (descending) - { - std::sort(range.begin(), range.end(), std::greater<>{}); - } - else - { - std::sort(range.begin(), range.end()); - } - } - - utility::write(std::cout, range); - } -} +#include int main (int argc, const char * argv[]) { @@ -95,7 +51,7 @@ int main (int argc, const char * argv[]) bool sort = vm["sort"].as(); bool descending = vm["descending"].as(); - generate(range_count, range_length, min, max, seed, sort, descending); + utility::generate(range_count, range_length, min, max, seed, sort, descending); } } catch (std::exception &) From 329f1bedc599a9200f66c40a49155227a1cc8afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=98=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Sat, 27 Jun 2020 03:01:19 +0300 Subject: [PATCH 6/6] =?UTF-8?q?refs=20#118=20=D0=91=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=B1=D1=89=D0=B8=D0=B9=20=D0=B8=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D1=84=D1=83=D0=BD=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/include/utility/io/generate.hpp | 9 ++++++--- benchmark/src/range_generator.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/benchmark/include/utility/io/generate.hpp b/benchmark/include/utility/io/generate.hpp index 22dd6927..0193fc72 100644 --- a/benchmark/include/utility/io/generate.hpp +++ b/benchmark/include/utility/io/generate.hpp @@ -8,15 +8,16 @@ #include #include #include -#include +#include #include #include namespace utility { - void + std::ostream & generate ( + std::ostream & stream, std::size_t range_count, std::size_t range_length, std::int64_t min, @@ -51,8 +52,10 @@ namespace utility } } - write(std::cout, range); + write(stream, range); } + + return stream; } } // namespace utility diff --git a/benchmark/src/range_generator.cpp b/benchmark/src/range_generator.cpp index b440f523..1c5f5a91 100644 --- a/benchmark/src/range_generator.cpp +++ b/benchmark/src/range_generator.cpp @@ -51,7 +51,7 @@ int main (int argc, const char * argv[]) bool sort = vm["sort"].as(); bool descending = vm["descending"].as(); - utility::generate(range_count, range_length, min, max, seed, sort, descending); + utility::generate(std::cout, range_count, range_length, min, max, seed, sort, descending); } } catch (std::exception &)