The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

Calculate report generation time between initialize and afterFactory events

Clement WongClement Wong EM mod
edited September 7, 2017 in DevShare
If we take a look at the order of events for report generation (, you'll find the following events where we calculate the time between the initialize and the afterFactory events.<br />
<br />
eventgen.jpg<br />
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() =={
	reportContext.setGlobalVariable("startTime", new Date());
<br />
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 &gt; Error Log window
//var logger = java.util.logging.Logger.getLogger("");
//logger.warning ( elapsedTime );														// Time in milliseconds
<br />
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");
<br />
This report was tested in OS BIRT 3.7.2, and in iHub 16.2.

Clement Wong
Principal Analytics Architect

OpenText Corporation |

Sign In or Register to comment.