summaryrefslogtreecommitdiff
path: root/aa.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-17 13:51:56 +0800
committerKeuin <[email protected]>2022-04-17 13:52:24 +0800
commit836eab89d8092b313c292db79be2aa450f8a059a (patch)
treec9bfff2849f6123013fb4bbfe1afc94cb7e0d69e /aa.h
parent3c57ce96a98ea00da80c4a2cef33e9db21c618ac (diff)
Calculate speed and display performance details. Do not allocate redundant image pixels.
Diffstat (limited to 'aa.h')
-rw-r--r--aa.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/aa.h b/aa.h
index f2dfd69..acdbc88 100644
--- a/aa.h
+++ b/aa.h
@@ -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);
}