Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Birt performance
vash
Hi,
I have a report design which consists of only tables and I am using REAPI to generate the pdf output. I have to use the same report to generate 'N' pdf files.
It takes around 27 seconds to generate one PDF.
Is there any way to enhance the performance?
Is there any way to loop to generate PDF for all 'N' files to reduce the time?
Vash
Find more posts tagged with
Comments
JasonW
Vash,
Are you creating a new engine every time? If so that would have very bad performance.
Jason
vash
Hi Jason,<br />
<br />
To reduce the time, I created a common start method for Platform.Startup and then I call the execute method in a loop.<br />
I am pasting my code here.<br />
I am taking my arguments as report parameter for my xml datasource.<br />
But as I am using a loop, it is giving me the following exception.<br />
<br />
public class PDFReport {<br />
<br />
private IReportEngine engine;<br />
private EngineConfig config;<br />
private IReportEngineFactory factory;<br />
private IReportRunnable design;<br />
private IRunAndRenderTask task;<br />
<br />
private void start() <br />
{ <br />
try{<br />
config = new EngineConfig( ); <br />
config.setBIRTHome("/home2/v/Desktop/birt-runtime/birt-runtime-2_3_1/ReportEngine");<br />
config.setLogConfig(null, Level.FINER);<br />
Platform.startup( config );<br />
<br />
factory = (IReportEngineFactory) Platform<br />
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );<br />
engine = factory.createReportEngine( config ); <br />
<br />
}catch (Exception e){<br />
e.printStackTrace();<br />
}<br />
}//start<br />
<br />
private void executeReport(String rep, String period, String coid) {<br />
<br />
String input = rep + "/" + period + "/" + coid + ".xml";<br />
String output = rep + "/" + period + "/" + coid + ".pdf";<br />
<br />
try { <br />
//Open the report design<br />
design = engine.openReportDesign("/home2/v/workspace/My Reports/bill_detailOLD.rptdesign"); <br />
task = engine.createRunAndRenderTask(design);<br />
task.setParameterValue("RP_source", input);<br />
task.setAppContext(contextMap);<br />
<br />
PDFRenderOption options = new PDFRenderOption();<br />
options.setOutputFileName(output);<br />
options.setOutputFormat("pdf");<br />
task.setRenderOption(options);<br />
task.run();<br />
task.close(); <br />
} catch (Exception e ) {<br />
e.printStackTrace();<br />
}<br />
}//execute<br />
<br />
<br />
private void shutdown() { <br />
<br />
engine.destroy();<br />
Platform.shutdown( );<br />
}//shutdown<br />
<br />
public static void main(String[] args) {<br />
String rep = args[0];<br />
String yrmonth = args[1];<br />
PDFReport object = new PDFReport();<br />
object.start();<br />
for (int i = 2; i < args.length; i++) {<br />
try{<br />
long start = System.currentTimeMillis();<br />
System.out.println(args
);<br />
object.executeReport(rep, yrmonth, args
);<br />
<br />
System.err.println("PDF create time : " + (System.currentTimeMillis() - start));<br />
}//try<br />
catch ( Exception e ){<br />
e.printStackTrace();<br />
}//catch<br />
finally{<br />
object.shutdown( ); <br />
}//finally<br />
}//for <br />
}//main<br />
<br />
} //class<br />
<br />
<br />
The exception that I am getting:<br />
java.lang.NullPointerException at org.eclipse.birt.report.engine.api.impl.ReportEngine.openReportDesign(ReportEngine.java:327)<br />
at PDFReport.executeReport(PDFReport.java:52)<br />
at PDFReport.main(PDFReport.java:87)<br />
<br />
<br />
Thanks for the help.<br />
vash
JasonW
Vash,
I do not see anything obviously wrong with the code. What specific line are you getting the error on? Also can you move this line to your start method
design = engine.openReportDesign("/home2/v/workspace/My Reports/bill_detailOLD.rptdesign");
You use the same design so you should only have to open it once.
Jason
vash
Hi Jason,
I moved that line in the start method.
It's killing me on:
task = engine.createRunAndRenderTask(design);
in the execute method.
Again the exception is:
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
JasonW
Vash,
Can you zip up the log file and attach it?
Jason
vash
Hi Jason,
I have attached the log file.
Please let me know if you need more information.
Thanks,
Vash
JasonW
Vash,
Does it die on the first iteration? I saw no errors in the log file. Can you try replacing your design with one of the sample reports for testing purposes?
Jason
vash
Jason,
First of all, I really appreciate your prompt replies.
No, its not dying on the first iteration.
It generates the pdf for the first one, but crashes on the second.
Which sample report are you talking about?
-Vash
vash
Hi Jason,
I tried using multiple_charts_param.rptdesign from the examples.
It runs well for the first iteration, but gives the same exception later.
The code that I used:
public class trial {
private IReportEngine engine;
private EngineConfig config;
private IReportEngineFactory factory;
private IReportRunnable design;
private IRunAndRenderTask task;
private void start()
{
try{
config = new EngineConfig( );
config.setBIRTHome("/home2/v/Desktop/birt-runtime/birt-runtime-2_3_1/ReportEngine");
config.setLogConfig("/home2/v/temp/test", Level.FINEST);
Platform.startup( config );
factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
design = engine.openReportDesign("/home2/v/Desktop/multiple_charts_param.rptdesign");
}catch (Exception e){
e.printStackTrace();
}
}//start
private void executeReport() {
try {
task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("/home2/v/Desktop/trial.pdf");
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
} catch (Exception e ) {
e.printStackTrace();
}
}//execute
private void shutdown() {
engine.destroy();
Platform.shutdown( );
}//shutdown
public static void main(String[] args) {
trial object = new trial();
object.start();
for (int i = 1; i < 10; i++) {
try{
long start = System.currentTimeMillis();
System.out.println(i);
object.executeReport();
System.err.println("PDF create time : " + (System.currentTimeMillis() - start));
}//try
catch ( Exception e ){
e.printStackTrace();
}//catch
finally{
object.shutdown( );
}//finally
}//for
}//main
} //class
Output:
1
Jan 21, 2009 2:20:21 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
INFO: Found JDBC driverinfo extension: driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
Jan 21, 2009 2:20:21 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
....... ( ALL the output messages)
INFO: load font config in bundleentry://9/fontsConfig_pdf.xml cost 5ms
PDF create time : 168338
2
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 1
3
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 1
4
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 1
5
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 1
6
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 1
7
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 14
8
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 11
9
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:391)
at trial.executeReport(trial.java:56)
at trial.main(trial.java:86)
PDF create time : 11
Can you please help me with this?
Thanks,
Vash
JasonW
Vash,
Try this:
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class Trial {
private static IReportEngine engine;
private static EngineConfig config;
private static IReportEngineFactory factory;
private static IReportRunnable design;
private static void start()
{
try{
config = new EngineConfig( );
config.setBIRTHome("C:birtbirt-runtime-2_3_1birt-runtime-2_3_1ReportEngine");
Platform.startup( config );
factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
design = engine.openReportDesign("Reports/simple.rptdesign");
}catch (Exception e){
e.printStackTrace();
}
}//start
public void executeReport() {
try {
IRunAndRenderTask task;
if( design != null){
System.out.println(design.getReportName());
task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("c:/test/logs/trial.pdf");
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
}
} catch (Exception e ) {
e.printStackTrace();
}
}//execute
public void shutdown() {
engine.destroy();
Platform.shutdown( );
}//shutdown
public void loop(Trial object){
for (int i = 1; i < 10; i++) {
long start = System.currentTimeMillis();
System.out.println(i);
object.executeReport();
System.err.println("PDF create time : " + (System.currentTimeMillis() - start));
}
}
public static void main(String[] args) {
Trial object = new Trial();
Trial.start();
object.loop(object);
object.shutdown();
}
}
vash
Jason,
It works perfectly.
And now the time is reduced exponentially.
Thank you so much for all the help.
I have one more question, but I will create a post with the right title for that.
Once again, thanks for all the help.
-Vash