2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-13 00:12:11 +00:00

Better timing information. Add wall clock info to -d+4 output. And use

wait4 which gives better resource usage times on Nix.
This commit is contained in:
Rene Rivera
2016-10-11 10:09:44 -05:00
parent dd06e0e68a
commit 2effafb5df
4 changed files with 16 additions and 18 deletions

View File

@@ -64,8 +64,6 @@ static int get_free_cmdtab_slot();
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
static clock_t tps;
static int old_time_initialized;
static struct tms old_time;
/* We hold stdout & stderr child process information in two element arrays
* indexed as follows.
@@ -178,13 +176,6 @@ void exec_cmd
exit( EXITBAD );
}
/* Initialize old_time only once. */
if ( !old_time_initialized )
{
times( &old_time );
old_time_initialized = 1;
}
/* Start the command */
timestamp_current( &cmdtab[ slot ].start_dt );
@@ -513,6 +504,7 @@ void exec_wait()
int status;
int rstat;
timing_info time_info;
struct rusage cmd_usage;
/* We found a terminated child process - our search is done. */
finished = 1;
@@ -523,7 +515,7 @@ void exec_wait()
close_streams( i, ERR );
/* Reap the child and release resources. */
while ( ( pid = waitpid( cmdtab[ i ].pid, &status, 0 ) ) == -1 )
while ( ( pid = wait4( cmdtab[ i ].pid, &status, 0, &cmd_usage ) ) == -1 )
if ( errno != EINTR )
break;
if ( pid != cmdtab[ i ].pid )
@@ -539,15 +531,10 @@ void exec_wait()
: EXIT_OK;
{
struct tms new_time;
times( &new_time );
time_info.system = (double)( new_time.tms_cstime -
old_time.tms_cstime ) / CLOCKS_PER_SEC;
time_info.user = (double)( new_time.tms_cutime -
old_time.tms_cutime ) / CLOCKS_PER_SEC;
time_info.system = ((double)(cmd_usage.ru_stime.tv_sec)*1000000.0+(double)(cmd_usage.ru_stime.tv_usec))/1000000.0;
time_info.user = ((double)(cmd_usage.ru_utime.tv_sec)*1000000.0+(double)(cmd_usage.ru_utime.tv_usec))/1000000.0;
timestamp_copy( &time_info.start, &cmdtab[ i ].start_dt );
timestamp_current( &time_info.end );
old_time = new_time;
}
/* Drive the completion. */

View File

@@ -854,7 +854,9 @@ static void make1c_closure
{
call_timing_rule( t, time );
if ( DEBUG_EXECCMD )
out_printf( "%f sec system; %f sec user\n", time->system, time->user );
out_printf( "%f sec system; %f sec user, %f sec clock\n",
time->system, time->user,
timestamp_delta_seconds(&time->start, &time->end) );
/* Assume -p0 is in effect, i.e. cmd_stdout contains merged output. */
call_action_rule( t, status_orig, time, cmd->buf->value, cmd_stdout );

View File

@@ -261,3 +261,11 @@ void timestamp_done()
hashdone( bindhash );
}
}
/*
* timestamp_delta_seconds() - seconds from time a to b.
*/
double timestamp_delta_seconds( timestamp const * const a , timestamp const * const b )
{
return ((b->secs*1000000.0+b->nsecs)-(a->secs*1000000.0+a->nsecs))/1000000.0;
}

View File

@@ -42,5 +42,6 @@ void timestamp_from_filetime( timestamp * const, FILETIME const * const );
#endif
void timestamp_done();
double timestamp_delta_seconds( timestamp const * const, timestamp const * const );
#endif