Author: sebor Date: Tue Nov 27 21:08:25 2007 New Revision: 598869 URL: http://svn.apache.org/viewvc?rev=598869&view=rev Log: 2007-11-27 Martin Sebor <[EMAIL PROTECTED]>
Merged rev 594730 from trunk with the implementation of STDCXX-623. * util/target.h (target_status): Changed the type of user, system, and wall clock time counters from clock_t* to plain clock_t and renamed to usr_time, sys_time, and wall_time, respectively. * util/exec.cpp (calculate_usage, exec_file): Eliminated static locals and instead directly used the target_status object passed in by caller. (exec_file): * util/display.cpp (print_status_plain, print_status_verbose): Checked for times equal to -1 as an indicator of validity. (print_footer_plain): Printed cumulative times for all targets. * util/runall.cpp (run_target): Accumulated target times. Modified: incubator/stdcxx/branches/4.2.x/util/display.cpp incubator/stdcxx/branches/4.2.x/util/exec.cpp incubator/stdcxx/branches/4.2.x/util/runall.cpp incubator/stdcxx/branches/4.2.x/util/target.h Modified: incubator/stdcxx/branches/4.2.x/util/display.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/util/display.cpp?rev=598869&r1=598868&r2=598869&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.x/util/display.cpp (original) +++ incubator/stdcxx/branches/4.2.x/util/display.cpp Tue Nov 27 21:08:25 2007 @@ -186,8 +186,9 @@ assert (0 != status); assert (ST_OK <= status->status && ST_LAST > status->status); - valid_timing = status->user && status->sys && - ST_NOT_KILLED != status->status; + valid_timing = status->usr_time != (clock_t)-1 + && status->sys_time != (clock_t)-1 + && ST_NOT_KILLED != status->status; if (status->status) /* if status is set, print it */ printf ("%6s", short_st_name [status->status]); @@ -214,18 +215,18 @@ printf (" 0 %6u 100%%", status->failed); } } - else if (valid_timing || status->wall) + else if (valid_timing || status->wall_time != (clock_t)-1) printf (" "); /* Print timings, if available */ if (valid_timing) - printf (" %7.3f %7.3f", (float) *status->user / TICKS_PER_SEC, - (float) *status->sys / TICKS_PER_SEC); - else if (status->wall) + printf (" %7.3f %7.3f", (float)status->usr_time / TICKS_PER_SEC, + (float)status->sys_time / TICKS_PER_SEC); + else if (status->wall_time != (clock_t)-1) printf (" "); - if (status->wall) - printf (" %7.3f\n", (float) *status->wall / TICKS_PER_SEC); + if (status->wall_time != (clock_t)-1) + printf (" %7.3f\n", (float)status->wall_time / TICKS_PER_SEC); else puts (""); } @@ -242,8 +243,9 @@ assert (0 != status); assert (ST_OK <= status->status && ST_LAST > status->status); - valid_timing = status->user && status->sys - && ST_NOT_KILLED != status->status; + valid_timing = status->usr_time != (clock_t)-1 + && status->sys_time != (clock_t)-1 + && ST_NOT_KILLED != status->status; if (status->status) /* if status is set, print it */ printf (" Status: %s\n", verbose_st_name [status->status]); @@ -269,9 +271,9 @@ /* Print timings, if available */ if (valid_timing) { - const float wall = status->wall ? *status->wall / TICKS_PER_SEC : -1; - const float user = status->user ? *status->user / TICKS_PER_SEC : -1; - const float sys = status->sys ? *status->sys / TICKS_PER_SEC : -1; + const float wall = (float)status->wall_time / TICKS_PER_SEC; + const float user = (float)status->usr_time / TICKS_PER_SEC; + const float sys = (float)status->sys_time / TICKS_PER_SEC; printf (" Times:\n" " Real %7.3fs\n" @@ -291,13 +293,18 @@ static void print_footer_plain (int count, const struct target_status *summary) { + /* compute cumulative times for all targets */ + const float wall = (float)summary->wall_time / TICKS_PER_SEC; + const float user = (float)summary->usr_time / TICKS_PER_SEC; + const float sys = (float)summary->sys_time / TICKS_PER_SEC; + printf ("PROGRAM SUMMARY:\n" - " Programs: %6d\n" - " Non-zero exit status: %6d\n" - " Signalled: %6d\n" - " Compiler warnings: %6u\n" - " Linker warnings: %6u\n" - " Runtime warnings: %6u\n", + " Programs: %9d\n" + " Non-zero exit status: %9d\n" + " Signalled: %9d\n" + " Compiler warnings: %9u\n" + " Linker warnings: %9u\n" + " Runtime warnings: %9u\n", count, summary->exit, summary->signaled, @@ -307,11 +314,19 @@ if ((unsigned)-1 != summary->assert) { /* print assertion counters only when they're valid */ - printf (" Assertions: %6u\n" - " Failed assertions: %6u\n", + printf (" Assertions: %9u\n" + " Failed assertions: %9u\n", summary->assert, summary->failed); } + + printf ( " Cumulative times:\n" + " Real %7.3fs\n" + " User %7.3fs\n" + " Sys %7.3fs\n", + wall, + user, + sys); } Modified: incubator/stdcxx/branches/4.2.x/util/exec.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/util/exec.cpp?rev=598869&r1=598868&r2=598869&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.x/util/exec.cpp (original) +++ incubator/stdcxx/branches/4.2.x/util/exec.cpp Tue Nov 27 21:08:25 2007 @@ -783,15 +783,12 @@ calculate_usage (struct target_status* result, const clock_t h_clk, const struct tms* const h_tms) { - static clock_t wall, user, sys; struct tms c_tms; clock_t c_clk; assert (0 != result); assert (0 != h_tms); - wall = user = sys = 0; - c_clk = times (&c_tms); if (-1 == c_clk) { @@ -800,14 +797,9 @@ } /* time calculations */ - wall = c_clk - h_clk; - user = c_tms.tms_cutime - h_tms->tms_cutime; - sys = c_tms.tms_cstime - h_tms->tms_cstime; - - /* Tag result as having run */ - result->wall = &wall; - result->user = &user; - result->sys = &sys; + result->wall_time = c_clk - h_clk; + result->usr_time = c_tms.tms_cutime - h_tms->tms_cutime; + result->sys_time = c_tms.tms_cstime - h_tms->tms_cstime; } void exec_file (const struct target_opts* options, struct target_status* result) @@ -1077,7 +1069,6 @@ {sizeof (SECURITY_ATTRIBUTES), NULL, TRUE}; DWORD real_timeout, wait_code; FILETIME start, end; - static clock_t wall; assert (0 != options); assert (0 != options->argv); @@ -1215,23 +1206,18 @@ #if _WIN32_WINNT >= 0x0500 FILETIME stime, utime; - static clock_t user, sys; - if (GetProcessTimes (child.hProcess, &start, &end, &stime, &utime)) { - user = clock_t (fttoull (utime) / UNITS_PER_CLOCK); - sys = clock_t (fttoull (stime) / UNITS_PER_CLOCK); - /* Link the delta */ - result->user = &user; - result->sys = &sys; + if (GetProcessTimes (child.hProcess, &start, &end, &stime, &utime)) { + result->usr_time = clock_t (fttoull (utime) / UNITS_PER_CLOCK); + result->sys_time = clock_t (fttoull (stime) / UNITS_PER_CLOCK); } else warn_last_error ("Getting child process times"); #endif // _WIN32_WINNT >= 0x0500 - wall = clock_t ((fttoull (end) - fttoull (start)) / UNITS_PER_CLOCK); + result->wall_time = + clock_t ((fttoull (end) - fttoull (start)) / UNITS_PER_CLOCK); - /* Link the delta */ - result->wall = &wall; if (0 == GetExitCodeProcess (child.hProcess, (LPDWORD)&result->exit)) { warn_last_error ("Retrieving child process exit code"); Modified: incubator/stdcxx/branches/4.2.x/util/runall.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/util/runall.cpp?rev=598869&r1=598868&r2=598869&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.x/util/runall.cpp (original) +++ incubator/stdcxx/branches/4.2.x/util/runall.cpp Tue Nov 27 21:08:25 2007 @@ -468,6 +468,16 @@ if (0 == results.signaled && results.exit) ++summary->exit; + /* add cumulative times (when valid) */ + if (results.usr_time != (clock_t)-1) + summary->usr_time += results.usr_time; + + if (results.sys_time != (clock_t)-1) + summary->sys_time += results.sys_time; + + if (results.wall_time != (clock_t)-1) + summary->wall_time += results.wall_time; + summary->signaled += results.signaled; summary->c_warn += results.c_warn; summary->l_warn += results.l_warn; @@ -533,7 +543,10 @@ set_output_format (FMT_PLAIN); if (0 < argc) { + struct target_status summary; + int i; + target_template.argv = split_opt_string (exe_opts); assert (0 != target_template.argv); @@ -541,7 +554,6 @@ /* print out the program's argv array in verbose mode */ print_header (target_template.verbose ? saved_argv : 0); - struct target_status summary; memset (&summary, 0, sizeof summary); /* number of program's executed */ Modified: incubator/stdcxx/branches/4.2.x/util/target.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/util/target.h?rev=598869&r1=598868&r2=598869&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.x/util/target.h (original) +++ incubator/stdcxx/branches/4.2.x/util/target.h Tue Nov 27 21:08:25 2007 @@ -121,9 +121,9 @@ int signaled; /**< 1 if exit is a signal number, 0 denoting exit code otherwise */ enum ProcessStatus status; /**< Textual process status. */ - const clock_t* user; /**< Elapsed user time spent in execution. */ - const clock_t* sys; /**< Elapsed system time spent in execution. */ - const clock_t* wall; /**< Wall clock time spent in execution. */ + clock_t usr_time; /**< Elapsed user time spent in execution. */ + clock_t sys_time; /**< Elapsed system time spent in execution. */ + clock_t wall_time; /**< Wall clock time spent in execution. */ unsigned c_warn; /**< Number of compile warnings. */ unsigned l_warn; /**< Number of link warnings. */ unsigned t_warn; /**< Number of (test) warnings. */