Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
180 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +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) | ||
|
||
add_subdirectory(algorithm) | ||
add_subdirectory(container) | ||
add_subdirectory(integer) | ||
add_subdirectory(iterator) | ||
add_subdirectory(burst) | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
add_subdirectory(algorithm) | ||
add_subdirectory(container) | ||
add_subdirectory(integer) | ||
add_subdirectory(iterator) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP | ||
#define BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP | ||
|
||
#include <utility/io/write.hpp> | ||
|
||
#include <algorithm> | ||
#include <chrono> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <functional> | ||
#include <ostream> | ||
#include <random> | ||
#include <vector> | ||
|
||
namespace utility | ||
{ | ||
std::ostream & | ||
generate | ||
( | ||
std::ostream & stream, | ||
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::default_random_engine::result_type> | ||
( | ||
std::chrono::system_clock::now().time_since_epoch().count() | ||
) | ||
: 0; | ||
std::default_random_engine engine(seed_value); | ||
std::uniform_int_distribution<std::int64_t> uniform(min, max); | ||
|
||
std::vector<std::int64_t> 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(stream, range); | ||
} | ||
|
||
return stream; | ||
} | ||
} // namespace utility | ||
|
||
#endif // BURST_BENCHMARK_UTILITY_IO_GENERATE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef BURST_BENCHMARK_UTILITY_IO_READ_HPP | ||
#define BURST_BENCHMARK_UTILITY_IO_READ_HPP | ||
|
||
#include <burst/functional/trivial_read.hpp> | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <istream> | ||
|
||
namespace utility | ||
{ | ||
template <typename Container> | ||
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<typename Container::value_type>(n); | ||
} | ||
} | ||
|
||
return stream; | ||
} | ||
} // namespace utility | ||
|
||
#endif // BURST_BENCHMARK_UTILITY_IO_READ_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP | ||
#define BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP | ||
|
||
#include <utility/io/read.hpp> | ||
|
||
#include <istream> | ||
|
||
namespace utility | ||
{ | ||
template <typename Container> | ||
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; | ||
} | ||
} // namespace utility | ||
|
||
#endif // BURST_BENCHMARK_UTILITY_IO_READ_MANY_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef BURST_BENCHMARK_UTILITY_IO_WRITE_HPP | ||
#define BURST_BENCHMARK_UTILITY_IO_WRITE_HPP | ||
|
||
#include <burst/functional/trivial_write.hpp> | ||
#include <burst/iterator/binary_ostream_iterator.hpp> | ||
|
||
#include <boost/range/algorithm/transform.hpp> | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <ostream> | ||
|
||
namespace utility | ||
{ | ||
template <typename Container> | ||
std::ostream & write (std::ostream & stream, const Container & values) | ||
{ | ||
burst::trivial_write(stream, static_cast<std::size_t>(values.size())); | ||
boost::transform(values, burst::make_binary_ostream_iterator(stream), | ||
[] (std::int64_t v) {return v;}); | ||
// Элементы контейнера должны уметь неявно (то есть без потерь) преобразовываться к | ||
// std::int64_t, т.к. это "официальный" формат обмена числами между приложениями. | ||
|
||
return stream; | ||
} | ||
} // namespace utility | ||
|
||
#endif // BURST_BENCHMARK_UTILITY_IO_WRITE_HPP |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(rangegen range_generator.cpp) | ||
target_link_libraries(rangegen PRIVATE Burst::burst benchIO Boost::program_options) |
Oops, something went wrong.