21void Internal::start_profiling (Profile &profile,
double s) {
25 profile.active =
true;
28void Internal::stop_profiling (Profile &profile,
double s) {
31 profile.value += s - profile.started;
32 profile.active =
false;
35double Internal::update_profiles () {
37#define PROFILE(NAME, LEVEL) \
39 Profile &profile = profiles.NAME; \
40 if (profile.active) { \
41 CADICAL_assert (profile.level <= opts.profile); \
42 profile.value += now - profile.started; \
43 profile.started = now; \
51double Internal::solve_time () {
52 (void) update_profiles ();
53 return profiles.solve.value;
57 MSG ("%s" S "%s", tout.magenta_code (), T, tout.normal_code ())
59void Internal::print_profile () {
60 double now = update_profiles ();
61 const char *time_type = opts.realtime ?
"real" :
"process";
63 PRT (
"%s time taken by individual solving procedures", time_type);
64 PRT (
"(percentage relative to %s time for solving)", time_type);
66 const size_t size =
sizeof profiles /
sizeof (Profile);
67 struct Profile *profs[
size];
69#define PROFILE(NAME, LEVEL) \
71 if (LEVEL > opts.profile) \
73 Profile *p = &profiles.NAME; \
74 if (p == &profiles.solve) \
76 if (!profiles.NAME.value && p != &profiles.parse && \
77 p != &profiles.search && p != &profiles.simplify) \
91 double solve = profiles.solve.value;
93 for (
size_t i = 0; i < n; i++) {
94 for (
size_t j = i + 1; j < n; j++)
96 swap (profs[i], profs[j]);
97 MSG (
"%12.2f %7.2f%% %s", profs[i]->
value,
98 percent (profs[i]->
value, solve), profs[i]->
name);
101 MSG (
" =================================");
102 MSG (
"%12.2f %7.2f%% solve", solve, percent (solve, now));
105 PRT (
"last line shows %s time for solving", time_type);
106 PRT (
"(percentage relative to total %s time)", time_type);
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define CADICAL_assert(ignore)
ABC_NAMESPACE_IMPL_START typedef signed char value