Jump to content

BIRT Developer Center Download


Photo
- - - - -

Execution time report


  • Please log in to reply
1 reply to this topic

#1 hugoscp1

hugoscp1

    Member

  • Members
  • PipPip
  • 10 posts

Posted 30 August 2017 - 04:14 AM

Hello, 
I want to know how to send to a label, or a text, the execution time of the report.

Thank you



#2 Clement Wong

Clement Wong

    Senior Member

  • BIRT Experts
  • 1204 posts

Posted 06 September 2017 - 08:29 PM

Generation phase?  If we take a look at the order of events for generation (http://www.eclipse.o...g/scripting.php), you'll find the following:

 

eventgen.jpg

 

First, we will save the start time in the initialize event.  We first need to detect which phase initialize is called because it's called twice, once for generation and another during rendering.

if(reportContext.getTaskType() == Packages.org.eclipse.birt.report.engine.api.IEngineTask.TASK_RUN){
	reportContext.setGlobalVariable("startTime", new Date());
}

Second, we will take the time at the afterFactory event.  We'll calculate the difference between the end and start time, and save this in a persistent global variable.

var elapsedTime =  new Date() - reportContext.getGlobalVariable ("startTime");
reportContext.setPersistentGlobalVariable ("reportRenderTime", elapsedTime.toString());

// This debugging is only available in commercial BIRT
//
// Messages will appear in the Eclipse > Error Log window
//
//var logger = java.util.logging.Logger.getLogger("birt.report.logger");
//logger.warning ( elapsedTime );														// Time in milliseconds

Finally, we'll insert a label into the report, and modify its onRender event.  We will write out the elapsed time in milliseconds in the label's text.

this.text = 'Report generation time (ms): ' + reportContext.getPersistentGlobalVariable("reportRenderTime");

This report was tested in OS BIRT 3.7.2, and in iHub 16.2.

 

Attached Files


Clement Wong
Principal Analytics Architect

OpenText Corporation
http://www.actuate.com | http://www.opentext.com