[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] getting the running time...




Computing running time of jobs, how do you do it ?..

Here's the answer from the condor_q source code:



ad->LookupInteger( ATTR_JOB_STATUS, job_status); ad->LookupInteger( ATTR_SERVER_TIME, cur_time); ad->LookupInteger( ATTR_SHADOW_BIRTHDATE, shadow_bday ); if ( current_run == false ) { ad->LookupFloat( ATTR_JOB_REMOTE_WALL_CLOCK, previous_runs ); } ... /* Compute total wall time as follows: previous_runs is not the * number of seconds accumulated on earlier runs. cur_time is the * time from the point of view of the schedd, and shadow_bday is the * epoch time from the schedd's view when the shadow was started for * this job. So, we figure out the time accumulated on this run by * computing the time elapsed between cur_time & shadow_bday. * NOTE: shadow_bday is set to zero when the job is RUNNING but the * shadow has not yet started due to JOB_START_DELAY parameter. And * shadow_bday is undefined (stale value) if the job status is not * RUNNING. So we only compute the time on this run if shadow_bday * is not zero and the job status is RUNNING. */ float total_wall_time = previous_runs + (cur_time - shadow_bday)*(job_status == RUNNING && shadow_bday);

At some point in the past, I wrote some Perl code to do this. Here is the relevant segment:

sub get_remote_time
{
    my $classad = $_[0];
    my $status = $classad->{"JobStatus"};
    my $server_time = $classad->{"ServerTime"};
    my $shadow_birthdate = $classad->{"ShadowBday"};
    my $previous_runs = $classad->{"RemoteWallClockTime"};

    if ($server_time == 0) {
        return -1;
    }

    my $total_wall_time = $previous_runs;
    if ($status == 2 && $shadow_birthdate != 0) {
        $total_wall_time += ($server_time - $shadow_birthdate);
    }
    return $total_wall_time;
}