[gold-users] gold perl api / gui

Scott Jackson scott at clusterresources.com
Thu Jul 19 15:46:33 MDT 2007


Hi Tim,

Unfortunately there is no "gold-ism" to do an average of a difference
between two fields. But how about this:

Since Avg(A - B) = ((A1 - B1) + (A2 - B2) + ... + (An - Bn)) / n = ((A1
+ A2 + ... +  An) - (B1 + B2 + ... + Bn))/ n,

assuming you were doing this as a query to the Job object, you could do
this something similar to:

    my $request = new Gold::Request(object => "Job", action => "Query");
    $request->setSelection("StartTime", "Count", "", "Count");
    $request->setSelection("StartTime", "Sum", "", "StartTotal");
    $request->setSelection("EndTime", "Sum", "", "EndTotal");
    $request->setSelection("User", "GroupBy");

Then parse the response and simply transform each row's
(Count,StartTotal,EndTotal) into a single column with the value
((EndTotal-StartTotal)/Count) in Perl wherever you wanted
(Avg(EndTime-StartTime)).

Note, the reason I used aliases was two-fold. First to distinguish the
name of the first two fields, second to avoid the automatic date
conversion that occurs in Gold::Client::displayResponse when a field
ends with the word Time.

The GUI does not convert to hours for this report. We were planning on
doing that at one point with a checkbox but it did not get done.

Obviously, this would just be a matter of dividing the value by 3600 if
the column name was an amount field (similar to how it is done with
$time_division in Gold::Client.pm ( $value =
sprintf("%.${currency_precision}f", $value/$time_division);.

I hope this helps,

Scott


On Mon, 2007-07-16 at 09:29 +0100, Tim Robinson wrote:
> Hello,
> 
> I am adding some extra columns to the output from Projects->Usage Report
> in the GUI. 
> 
> One thing I'm stuck with is how to do a select that performs
> mathematical operations on job attributes, eg. plus or minus. Two
> specific examples I need are:
> 
> Average "queueing time". ie. average of (g_start_time -
> g_submission_time)
> 
> Average "job efficiency". ie. average of (g_cpu_duration -
> g_wall_duration*g_processors)
> 
> One other thing, I was wondering how to present results in hours rather
> than seconds with the gui.
> 
> Thanks for assistance,
> Best regards
> Tim
>  
> 
> 
>   



More information about the gold-users mailing list