114 using view_t = Kokkos::View<double*, execution_space>;
119 timer_external.reset();
120 timer.start(this->exec);
122 const view_t my_view(Kokkos::view_alloc(Kokkos::WithoutInitializing, this->exec,
"my view"), 10);
123 Kokkos::deep_copy(exec, my_view, 1.0);
125 timer.stop(this->exec);
134 const auto elapsed_external = timer_external.seconds();
136 ASSERT_LE(elapsed, elapsed_external);
137 ASSERT_GE(elapsed, 0.);
138 ASSERT_GE(elapsed_external, 0.);
146 if constexpr (std::same_as<TypeParam, void>) {
149 timer.start(this->exec);
152 std::this_thread::sleep_for(std::chrono::milliseconds(100));
154 if constexpr (std::same_as<TypeParam, void>) {
157 timer.stop(this->exec);
160 const double elapsed =
timer.template duration<milliseconds>().count();
163 ASSERT_GE(elapsed, 100.);
166 const auto duration_ms =
timer.template duration<milliseconds>();
167 ASSERT_NEAR(duration_ms.count(), elapsed, 1e-3);
170 const auto duration_us =
timer.template duration<microseconds>();
171 ASSERT_NEAR(duration_us.count(), elapsed * 1e3, 1.);
174 const auto duration_se =
timer.template duration<seconds>();
175 ASSERT_NEAR(duration_se.count(), elapsed / 1e3, 1e-6);
178 ASSERT_LE(abs(duration_ms - duration_us), std::chrono::microseconds(1));
179 ASSERT_LE(abs(duration_ms - duration_se), std::chrono::microseconds(1));
182 ASSERT_EQ(duration_ms, (
timer.template duration<milliseconds>()));
205 constexpr size_t nreps = 10;
207 constexpr std::chrono::milliseconds wait(14);
211 for(
size_t irep = 0; irep < nreps; ++irep)
215 timer.start(this->exec);
217 this->exec.fence(
"ensure that the event 'started'");
219 std::this_thread::sleep_for(wait);
221 timer.stop(this->exec);
225 const seconds elapsed_external(timer_external.seconds());
230 ASSERT_GE(elapsed, wait);
231 ASSERT_LE(elapsed, elapsed_external);
std::chrono::duration< double, std::ratio< 1, 1 > > seconds
Similar to std::chrono::seconds, but using double instead of an integer type to represent the tick co...