Commit 9eb92979 authored by nagayama15's avatar nagayama15

プロセス時間計測に`chrono`ではなく`std::clock()`を使用するように変更

parent b40c6c4f
bin/ bin/
obj/ obj/
.vscode/
#include <array> #include <ctime>
#include <chrono>
#include <cstddef> #include <cstddef>
#include <iostream> #include <cstdio>
#include <array>
#include <random> #include <random>
#include <vector> #include <vector>
...@@ -36,11 +36,11 @@ namespace ...@@ -36,11 +36,11 @@ namespace
} }
template <typename F> template <typename F>
std::chrono::high_resolution_clock::duration measure(F&& f) std::clock_t measure(F&& f)
{ {
const auto start = std::chrono::high_resolution_clock::now(); const auto start = std::clock();
f(); f();
const auto end = std::chrono::high_resolution_clock::now(); const auto end = std::clock();
return end - start; return end - start;
} }
...@@ -85,7 +85,7 @@ int main() ...@@ -85,7 +85,7 @@ int main()
return std::vector<std::byte>(std::begin(data), std::end(data)); return std::vector<std::byte>(std::begin(data), std::end(data));
}(); }();
std::cout << "compression[us],decompression[us]" << std::endl; std::puts("compression[us], decompression[us]");
constexpr std::size_t n = 100; constexpr std::size_t n = 100;
...@@ -101,8 +101,11 @@ int main() ...@@ -101,8 +101,11 @@ int main()
decompression_test(compressed_test_data, output_buffer); decompression_test(compressed_test_data, output_buffer);
}); });
std::cout std::printf(
<< std::chrono::duration_cast<std::chrono::microseconds>(compression_time).count() << "," "%f, %f\n",
<< std::chrono::duration_cast<std::chrono::microseconds>(decompression_time).count() << std::endl; 1e6 * compression_time / CLOCKS_PER_SEC,
1e6 * decompression_time / CLOCKS_PER_SEC);
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