diff --git a/src/0002.concatstring/concat_string.cc b/src/0002.concatstring/concat_string.cc index 50b0e33..0de9823 100644 --- a/src/0002.concatstring/concat_string.cc +++ b/src/0002.concatstring/concat_string.cc @@ -2,43 +2,39 @@ #include #include -struct benchmark_return -{ - std::size_t total_size{}; - fast_io::unix_timestamp timestamp{}; +struct benchmark_return { + std::size_t total_size{}; + fast_io::unix_timestamp timestamp{}; }; -template -inline benchmark_return benchmark(Func meth) -{ - std::size_t total_size{}; - auto start{fast_io::posix_clock_gettime(fast_io::posix_clock_id::monotonic_raw)}; - for (std::uint_least16_t r{}; r != 256; ++r) - { - for (std::uint_least16_t g{}; g != 256; ++g) - { - for (std::uint_least16_t b{}; b != 256; ++b) - { - total_size += meth(static_cast<::std::uint_least8_t>(r), static_cast<::std::uint_least8_t>(g), - static_cast<::std::uint_least8_t>(b)) - .size(); - } - } - } - return {total_size, fast_io::posix_clock_gettime(fast_io::posix_clock_id::monotonic_raw) - start}; +template inline benchmark_return benchmark(Func meth) { + std::size_t total_size{}; + auto start{ + fast_io::posix_clock_gettime(fast_io::posix_clock_id::monotonic_raw)}; + for (std::uint_least16_t r{}; r != 256; ++r) { + for (std::uint_least16_t g{}; g != 256; ++g) { + for (std::uint_least16_t b{}; b != 256; ++b) { + total_size += meth(static_cast<::std::uint_least8_t>(r), + static_cast<::std::uint_least8_t>(g), + static_cast<::std::uint_least8_t>(b)) + .size(); + } + } + } + return {total_size, + fast_io::posix_clock_gettime(fast_io::posix_clock_id::monotonic_raw) - + start}; } -inline auto color_concat (std::uint_least8_t r, std::uint_least8_t g, std::uint_least8_t b) -{ - return ::fast_io::concat("Red: ", r, ", Green: ", g, ", Blue: ", b); +inline auto color_concat(std::uint_least8_t r, std::uint_least8_t g, + std::uint_least8_t b) { + return ::fast_io::concat_std("Red: ", r, ", Green: ", g, ", Blue: ", b); } - -int main() -{ - auto concat_time = benchmark(color_concat); - using namespace fast_io::io; - print("fast_io::concat (total size: ", - concat_time.total_size, ") took ", concat_time.timestamp, - "s.\n"); +int main() { + auto concat_time = benchmark(color_concat); + using namespace fast_io::io; + perrln("concat_string:", concat_time.timestamp, "s"); + print("fast_io::concat_std (total size: ", concat_time.total_size, ") took ", + concat_time.timestamp, "s.\n"); } diff --git a/src/0006.vector_push_back/vector_push_back.cc b/src/0006.vector_push_back/vector_push_back.cc index 68d2bb4..d3b52a7 100644 --- a/src/0006.vector_push_back/vector_push_back.cc +++ b/src/0006.vector_push_back/vector_push_back.cc @@ -4,7 +4,7 @@ int main() { - constexpr ::std::size_t N{20000000}; + constexpr ::std::size_t N{5000000}; ::std::size_t capacity{}; { ::fast_io::timer timer_total(u8"::fast_io::vector<::std::size_t>");