Commit 7f423559 authored by nagayama15's avatar nagayama15

zlib伸長関数のベンチマークを無効化

parent fda8ef19
...@@ -22,6 +22,7 @@ namespace ...@@ -22,6 +22,7 @@ namespace
::deflateEnd(&zs); ::deflateEnd(&zs);
} }
#if defined(ENABLE_INFLATE_BENCHMARK)
void decompression_test(const std::vector<std::byte>& compressed_test_data, std::vector<std::byte>& buffer) void decompression_test(const std::vector<std::byte>& compressed_test_data, std::vector<std::byte>& buffer)
{ {
::z_stream zs = {}; ::z_stream zs = {};
...@@ -34,6 +35,7 @@ namespace ...@@ -34,6 +35,7 @@ namespace
::inflate(&zs, Z_FINISH); ::inflate(&zs, Z_FINISH);
::inflateEnd(&zs); ::inflateEnd(&zs);
} }
#endif
template <typename F> template <typename F>
std::clock_t measure(F&& f) std::clock_t measure(F&& f)
...@@ -67,6 +69,7 @@ int main() ...@@ -67,6 +69,7 @@ int main()
return data; return data;
}(); }();
#if defined(ENABLE_INFLATE_BENCHMARK)
// Compressed `test_data`. // Compressed `test_data`.
const auto compressed_test_data = [&]() const auto compressed_test_data = [&]()
{ {
...@@ -84,8 +87,13 @@ int main() ...@@ -84,8 +87,13 @@ int main()
return std::vector<std::byte>(std::begin(data), std::end(data)); return std::vector<std::byte>(std::begin(data), std::end(data));
}(); }();
#endif
#if defined(ENABLE_INFLATE_BENCHMARK)
std::puts("compression[us]\tdecompression[us]"); std::puts("compression[us]\tdecompression[us]");
#else
std::puts("compression[us]");
#endif
constexpr std::size_t n = 100; constexpr std::size_t n = 100;
...@@ -98,15 +106,23 @@ int main() ...@@ -98,15 +106,23 @@ int main()
compression_test(raw_test_data, output_buffer, 9); compression_test(raw_test_data, output_buffer, 9);
}); });
#if defined(ENABLE_INFLATE_BENCHMARK)
const auto decompression_time = measure([&]() const auto decompression_time = measure([&]()
{ {
decompression_test(compressed_test_data, output_buffer); decompression_test(compressed_test_data, output_buffer);
}); });
#endif
#if defined(ENABLE_INFLATE_BENCHMARK)
std::printf( std::printf(
"%f\t%f\n", "%f\t%f\n",
1e6 * compression_time / CLOCKS_PER_SEC, 1e6 * compression_time / CLOCKS_PER_SEC,
1e6 * decompression_time / CLOCKS_PER_SEC); 1e6 * decompression_time / CLOCKS_PER_SEC);
#else
std::printf(
"%f\n",
1e6 * compression_time / CLOCKS_PER_SEC);
#endif
std::fflush(stdout); std::fflush(stdout);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment