diff options
author | Keuin <[email protected]> | 2022-04-17 13:51:56 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-17 13:52:24 +0800 |
commit | 836eab89d8092b313c292db79be2aa450f8a059a (patch) | |
tree | c9bfff2849f6123013fb4bbfe1afc94cb7e0d69e | |
parent | 3c57ce96a98ea00da80c4a2cef33e9db21c618ac (diff) |
Calculate speed and display performance details. Do not allocate redundant image pixels.
-rw-r--r-- | aa.h | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -33,7 +33,7 @@ public: static constexpr auto seed = 123456789012345678ULL; const unsigned thread_count = std::min(std::thread::hardware_concurrency(), samples); std::cerr << "Preparing tasks..." << std::endl; - std::vector<bitmap<T>> images{samples, {1, 1}}; + std::vector<bitmap<T>> images{samples, {0,0}}; std::mt19937_64 seedgen{seed}; // generates seeds for workers const struct s_render_shared { @@ -56,8 +56,10 @@ public: }; thread_pool<s_render_task> pool{thread_count}; + timer tim{true}; - + std::cerr << "Seeding tasks..." << std::endl; + tim.start_measure(); for (typeof(samples) i = 0; i < samples; ++i) { pool.submit_task([](s_render_task &task) { bias_ctx bc{seed}; @@ -70,10 +72,16 @@ public: .task_id = i, .seed=seedgen(), .diffuse_seed=seedgen(), .shared=s_ }); } + tim.stop_measure(); + std::cerr << "Finish seeding. Speed: " << 1.0 * samples / tim.duration().count() << " task/sec" << std::endl; std::cerr << "Rendering with " << thread_count << " thread(s)." << std::endl; + tim.start_measure(); pool.start(); pool.wait(); + tim.stop_measure(); + std::cerr << "Finish rendering sub-pixels. Speed: " << 1.0 * tim.duration().count() / samples << "sec/image, " + << 1.0 * samples * image_width * image_height / tim.duration().count() << " pixel/sec" << std::endl; return bitmap<T>::average(images); } |