summaryrefslogtreecommitdiff
path: root/timer.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-11 22:13:57 +0800
committerKeuin <[email protected]>2022-04-11 22:13:57 +0800
commit43714bd116945573e7e4c854445462afa7f9b1b4 (patch)
tree7570dd1ab5e0feb38e504b4a49f4e8d2d0774873 /timer.h
parentf6661b0243cb359fb4929aee06d1247944f3d2dd (diff)
Implement ray3, timer and a simple viewport scanner.
Fix bitmap wrong pixel sequence. Remove default constructor of bitmap. Add pixel mixture method.
Diffstat (limited to 'timer.h')
-rw-r--r--timer.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/timer.h b/timer.h
new file mode 100644
index 0000000..1f100cd
--- /dev/null
+++ b/timer.h
@@ -0,0 +1,27 @@
+//
+// Created by Keuin on 2022/4/11.
+//
+
+#ifndef RT_TIMER_H
+#define RT_TIMER_H
+
+#include <iostream>
+#include <chrono>
+
+class timer {
+private:
+ typeof(std::chrono::system_clock::now()) start_time;
+public:
+ void start_measure() {
+ fprintf(stderr, "Start timing...\n");
+ start_time = std::chrono::system_clock::now();
+ }
+ void stop_measure() {
+ const auto end = std::chrono::system_clock::now();
+ const auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start_time);
+ const auto secs = 1e-3 * duration.count() * std::chrono::microseconds::period::num / std::chrono::microseconds::period::den;
+ fprintf(stderr, "Stop timing. Duration: %fs\n", secs);
+ }
+};
+
+#endif //RT_TIMER_H