From 123622ec99a3882a71ffb0b80ad6801a183d17d1 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Wed, 7 Aug 2024 14:44:11 -0400 Subject: [PATCH 1/4] vector --- src/0006.vector_push_back/vector_push_back.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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>"); From 142d1d8e23bb43c98b941ac9821bb5a1690131c0 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Thu, 8 Aug 2024 22:06:21 -0400 Subject: [PATCH 2/4] concat_string --- src/0002.concatstring/concat_string.cc | 66 ++++++++++++-------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/0002.concatstring/concat_string.cc b/src/0002.concatstring/concat_string.cc index 50b0e33..1b5824b 100644 --- a/src/0002.concatstring/concat_string.cc +++ b/src/0002.concatstring/concat_string.cc @@ -1,44 +1,40 @@ -#include -#include +#include +#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("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 (total size: ", concat_time.total_size, ") took ", + concat_time.timestamp, "s.\n"); } From debc54b1de9c2d824073299ec09480f3b814bcf4 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Thu, 8 Aug 2024 22:52:12 -0400 Subject: [PATCH 3/4] fix concat_string --- src/0002.concatstring/concat_string.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/0002.concatstring/concat_string.cc b/src/0002.concatstring/concat_string.cc index 1b5824b..6bbedc3 100644 --- a/src/0002.concatstring/concat_string.cc +++ b/src/0002.concatstring/concat_string.cc @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include struct benchmark_return { From 2152f0d71c07cebec6f221e41751587125d8f501 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:24:46 -0500 Subject: [PATCH 4/4] Update concat_string.cc --- src/0002.concatstring/concat_string.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/0002.concatstring/concat_string.cc b/src/0002.concatstring/concat_string.cc index 6bbedc3..0de9823 100644 --- a/src/0002.concatstring/concat_string.cc +++ b/src/0002.concatstring/concat_string.cc @@ -28,13 +28,13 @@ template inline benchmark_return benchmark(Func meth) { 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); + return ::fast_io::concat_std("Red: ", r, ", Green: ", g, ", Blue: ", b); } int main() { auto concat_time = benchmark(color_concat); using namespace fast_io::io; perrln("concat_string:", concat_time.timestamp, "s"); - print("fast_io::concat (total size: ", concat_time.total_size, ") took ", + print("fast_io::concat_std (total size: ", concat_time.total_size, ") took ", concat_time.timestamp, "s.\n"); }