return Period::num*double(duration.count())/Period::den;
}
+ /**
+ * Fill a MinMaxAvg struct with default values.
+ */
+ void
+ clear_timing_data(Utilities::MPI::MinMaxAvg &data)
+ {
+ data.sum = numbers::signaling_nan<double>();
+ data.min = numbers::signaling_nan<double>();
+ data.max = numbers::signaling_nan<double>();
+ data.avg = numbers::signaling_nan<double>();
+ data.min_index = numbers::invalid_unsigned_int;
+ data.max_index = numbers::invalid_unsigned_int;
+ }
}
}
}
mpi_communicator (mpi_communicator),
sync_wall_time(sync_wall_time_)
{
- last_lap_data.sum = last_lap_data.min = last_lap_data.max = last_lap_data.avg = numbers::signaling_nan<double>();
- last_lap_data.min_index = last_lap_data.max_index = numbers::invalid_unsigned_int;
- accumulated_wall_time_data.sum = accumulated_wall_time_data.min = accumulated_wall_time_data.max = accumulated_wall_time_data.avg = 0.;
- accumulated_wall_time_data.min_index = accumulated_wall_time_data.max_index = 0;
-
+ reset();
start();
}
{
wall_times.reset();
cpu_times.reset();
- running = false;
- last_lap_data.sum = last_lap_data.min = last_lap_data.max = last_lap_data.avg = numbers::signaling_nan<double>();
- last_lap_data.min_index = last_lap_data.max_index = numbers::invalid_unsigned_int;
- accumulated_wall_time_data.sum = accumulated_wall_time_data.min = accumulated_wall_time_data.max = accumulated_wall_time_data.avg = 0.;
- accumulated_wall_time_data.min_index = accumulated_wall_time_data.max_index = 0;
+ running = false;
+ internal::Timer::clear_timing_data(last_lap_data);
+ internal::Timer::clear_timing_data(accumulated_wall_time_data);
}
}
}
+// check that the MinMaxAvg is set to a default, unpopulated state.
+void
+assert_min_max_avg_invalid(const Utilities::MPI::MinMaxAvg &data)
+{
+ // we want to explicitly check that some things are signaling NaNs, so
+ // disable FP exceptions if they are on
+#if defined(DEBUG) && defined(DEAL_II_HAVE_FP_EXCEPTIONS)
+ fedisableexcept(FE_INVALID);
+#endif
+
+ AssertThrow(std::isnan(data.min), ExcInternalError());
+ AssertThrow(std::isnan(data.max), ExcInternalError());
+ AssertThrow(std::isnan(data.avg), ExcInternalError());
+ AssertThrow(data.min_index == numbers::invalid_unsigned_int, ExcInternalError());
+ AssertThrow(data.max_index == numbers::invalid_unsigned_int, ExcInternalError());
+}
+
+// check that the MinMaxAvg values are reasonable.
+void
+assert_min_max_avg_valid(const Utilities::MPI::MinMaxAvg &data)
+{
+ AssertThrow(data.min > 0., ExcInternalError());
+ AssertThrow(data.max >= data.min, ExcInternalError());
+ AssertThrow(data.avg >= data.min, ExcInternalError());
+ AssertThrow(data.min_index != numbers::invalid_unsigned_int, ExcInternalError());
+ AssertThrow(data.max_index != numbers::invalid_unsigned_int, ExcInternalError());
+}
void
AssertThrow(old_wall_time > 0., ExcInternalError());
const double old_cpu_time = t.wall_time();
AssertThrow(old_cpu_time > 0., ExcInternalError());
- AssertThrow(t.get_total_data().max == 0., ExcInternalError());
+ assert_min_max_avg_invalid(t.get_data());
+ assert_min_max_avg_invalid(t.get_total_data());
+ assert_min_max_avg_invalid(t.get_last_lap_data());
+ assert_min_max_avg_invalid(t.get_accumulated_wall_time_data());
burn(50);
AssertThrow(t.stop() > 0., ExcInternalError());
+ assert_min_max_avg_valid(t.get_data());
+ assert_min_max_avg_valid(t.get_total_data());
+ assert_min_max_avg_valid(t.get_last_lap_data());
+ assert_min_max_avg_valid(t.get_accumulated_wall_time_data());
AssertThrow(t.wall_time() > old_wall_time, ExcInternalError());
AssertThrow(t.cpu_time() > old_cpu_time, ExcInternalError());
AssertThrow(t.last_wall_time() > 0., ExcInternalError());
AssertThrow(t.last_cpu_time() > 0., ExcInternalError());
- AssertThrow(t.get_data().min > 0., ExcInternalError());
- AssertThrow(t.get_total_data().min > 0., ExcInternalError());
t.reset();
AssertThrow(t.wall_time() == 0., ExcInternalError());
AssertThrow(t.cpu_time()== 0., ExcInternalError());
- AssertThrow(t.get_total_data().max == 0, ExcInternalError());
+ assert_min_max_avg_invalid(t.get_data());
+ assert_min_max_avg_invalid(t.get_total_data());
+ assert_min_max_avg_invalid(t.get_last_lap_data());
+ assert_min_max_avg_invalid(t.get_accumulated_wall_time_data());
deallog << "OK" << std::endl;
}
test_timer(t1);
test_timer(t2);
}
-