1
votes

I have a customization package that calculates for payroll. it has batch processing page where it processes selected employee's payroll based on cut-off start and cut-off end. I know that a processing page has it's own "time indicator" and was just wondering if that is accurate. I wish to benchmark the performance of our code and get the time processed per employee whether by displaying it, or saving it on a log file. how can we achieve this? some sample code will be greatly appreciated.

1

1 Answers

1
votes

I have had a similar need. You can use PX.Data.PXLongOperation.GetStatus. My example below uses it in an Extension method to make it easier:

public static TimeSpan GetLongRunningTimeSpan<T>(this T graph) where T : PX.Data.PXGraph
{
    TimeSpan timespan;
    Exception ex;
    PX.Data.PXLongOperation.GetStatus(graph.UID, out timespan, out ex);
    return timespan;
}

The TimeSpan value will contain the current run time of your long running process.

If using the extension method you can then just call this.GetLongRunningTimeSpan() inside your graph process.

To display the values, you can send a message to the Acumatica trace window using PXTrace.WriteInformation. Here is an example:

PXTrace.WriteInformation("Employee {0} processed in {1} seconds",
      someEmployee, graph.GetLongRunningTimeSpan().TotalSeconds);

After your process is finished, go to Help > Trace and you should see the messages.