Forum


Replies: 10   Views: 3832
Speed issue
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by i-cre8  · 24-09-2015 - 21:09

I have 2 test subdomains set-up, one replicating our live site using ver3.3 Corporate and a second with the new ver5 corporate upgrade that I purchased the other day. version 3.3 the process: Create 17 docx files from a template, convert each of them to a pdf using libreoffice in headless mode and then join the pdf's together using a library called PDFMerger This takes on average 19 seconds version 5 the process: Create the same 17 docx files from the same template, merge them using the mergeDocx function and then use the conversion plugin to turn this merged file into a pdf This takes on average 32 seconds I am using the same data to create these files so I assumed that the latest version would be as quick if not quicker than my existing code, any ideas on why this should not be the case ?

Posted by admin  · 25-09-2015 - 07:45

Hello, Phpdocx 5 has the same speed than phpdocx 4 (it's faster than version 3). We see some differences on your environments: · ver 3.3: using OpenOffice (LibreOffice wasn't supported in this version) with headless mode and an external library. · ver 5: using LibreOffice (did you try OpenOffice in headless mode instead of the LibreOffice plugin?) and the MultiMerge class. We recommend you to run each step standalone and get its time to know where you could optimize it. Also be aware that merging DOCX documents is much more complex than merging PDF documents; when you merge DOCX you need to be aware of a lot of content that is painted dinamically (a PDF is more similar to an image than a DOCX). Regards.

Posted by i-cre8  · 25-09-2015 - 12:00

Hi, libreoffice is installed on the server, actually at one of your staff's suggestion, and I use this outside of the phpdocx conversion on the live server So to be more precise on the live site using ver3.3 I create the docx files using PHPDocx and then another php file converts them to pdf as a separate process like so: ## set command $myCommand = '/usr/bin/libreoffice --headless --nologo --convert-to pdf /usr/www/users/***********/_plugins/site-pages/public/tags-pages/temp/'.$_SESSION['clientSlug'].$_SESSION['i8_UniqueKey'].'tag_*.docx --outdir /usr/www/users/***********/_plugins/site-pages/public/tags-pages/temp'; ## create pdf's exec($myCommand,$output); foreach($output as $line){ print $line . "\r\n"; } and then I merge them using an external library I don't have access to OpenOffice on the server unfortunately but as your suggestion I will do some testing on the individual steps and come back to you with the results. ON your last point interestingly the whole process was slower still creating individual pdf's via the transform method and then merging the pdf's when I tested last night but again I will benchmark the steps. Thanks

Posted by i-cre8  · 28-09-2015 - 11:54

ok, so using an app called charles I have benchmarked the time taken to produce 17 docx files using the same data and template file using ver3.3 Corporate and Ver 5 Corporate Ver5 Corporate Response Times URL http://new.************.com/_plugins/ajax/print-tags.php Status Complete Response Code 200 OK Protocol HTTP/1.1 Method POST Kept Alive No Content-Type text/html Client Address /127.0.0.1 Remote Address new.************.com/216.**.***.*** Timing Request Start Time 28/09/15 12:44:16 Request End Time 28/09/15 12:44:16 Response Start Time 28/09/15 12:44:17 Response End Time 28/09/15 12:44:24 Duration 8.55 sec DNS - Connect 105 ms SSL Handshake - Request 0 ms Response 6.99 sec Latency 1.46 sec Speed 2.71 KB/s Response Speed 0.28 KB/s Size Request Header 1.05 KB (1076 bytes) Response Header 325 bytes Request 20.15 KB (20629 bytes) Response 1.65 KB (1694 bytes) Total 23.17 KB (23724 bytes) Ver3.3 Corporate Response Times URL http://development.************.com/_plugins/ajax/print-tags.php Status Complete Response Code 200 OK Protocol HTTP/1.1 Method POST Kept Alive No Content-Type text/html Client Address /127.0.0.1 Remote Address development.************.com/216.**.***.*** Timing Request Start Time 28/09/15 12:40:16 Request End Time 28/09/15 12:40:16 Response Start Time 28/09/15 12:40:19 Response End Time 28/09/15 12:40:42 Duration 25.37 sec DNS - Connect 99 ms SSL Handshake - Request 0 ms Response 22.64 sec Latency 2.63 sec Speed 0.91 KB/s Response Speed 0.09 KB/s Size Request Header 1.01 KB (1033 bytes) Response Header 325 bytes Request 20.15 KB (20629 bytes) Response 1.65 KB (1694 bytes) Total 23.13 KB (23681 bytes) As you will see the old code takes about a third of the time to complete compared to the new code. I am happy to send you the files privately so you can compare but this cannot be right surely ?

Posted by i-cre8  · 28-09-2015 - 11:55

gah, I have the headers for the files the wrong way round they should read Ver3.3 Corporate Response Times URL http://new.************.com/_plugins/ajax/print-tags.php Status Complete Response Code 200 OK Protocol HTTP/1.1 Method POST Kept Alive No Content-Type text/html Client Address /127.0.0.1 Remote Address new.************.com/216.**.***.*** Timing Request Start Time 28/09/15 12:44:16 Request End Time 28/09/15 12:44:16 Response Start Time 28/09/15 12:44:17 Response End Time 28/09/15 12:44:24 Duration 8.55 sec DNS - Connect 105 ms SSL Handshake - Request 0 ms Response 6.99 sec Latency 1.46 sec Speed 2.71 KB/s Response Speed 0.28 KB/s Size Request Header 1.05 KB (1076 bytes) Response Header 325 bytes Request 20.15 KB (20629 bytes) Response 1.65 KB (1694 bytes) Total 23.17 KB (23724 bytes) Ver5 Corporate Response Times URL http://development.************.com/_plugins/ajax/print-tags.php Status Complete Response Code 200 OK Protocol HTTP/1.1 Method POST Kept Alive No Content-Type text/html Client Address /127.0.0.1 Remote Address development.************.com/216.**.***.*** Timing Request Start Time 28/09/15 12:40:16 Request End Time 28/09/15 12:40:16 Response Start Time 28/09/15 12:40:19 Response End Time 28/09/15 12:40:42 Duration 25.37 sec DNS - Connect 99 ms SSL Handshake - Request 0 ms Response 22.64 sec Latency 2.63 sec Speed 0.91 KB/s Response Speed 0.09 KB/s Size Request Header 1.01 KB (1033 bytes) Response Header 325 bytes Request 20.15 KB (20629 bytes) Response 1.65 KB (1694 bytes) Total 23.13 KB (23681 bytes)

Posted by admin  · 28-09-2015 - 14:27

Hello, Please send the scripts and the DOCX templates to contact[at]phpdocx.com and we'll check them. As we need to run these scripts please don't do external connections (such as databases or web services). Regards.

Posted by i-cre8  · 28-09-2015 - 15:21

ok, I'll put a zip together with all the relevant files and send it to you tomorrow. Just as an aside I have run the template through the process I found here: http://www.phpdocx.com/api-documentation/templates/proccess-a-word-docx-template as well and that made a small difference to the time taken

Posted by i-cre8  · 28-09-2015 - 21:36

I have sent you an email as requested, one thing I have noticed is that the docx files created by version 5 are significantly larger in size (mb) than the ones created by version 3

Posted by admin  · 29-09-2015 - 06:52

Hello, We have checked your scripts. The problem is that each time you replace a variable, phpdocx repairs the template variables to avoid unwanted tags in the placeholders (sometimes Word adds spelling tags when writting the words). To avoid this automatically repairing function, you just need to set the preprocessed parameter as true when you instanciate CreateDocxFromTemplate: $docx = new CreateDocxFromTemplate('templates/Classic 3TAGS VERTICAL LOGO.docx', array('preprocessed' => true)); After doing this minor change, you'll get these output: The file using Corporate Version 5 created 17 docx files in 2.249489068985 seconds The file using Corporate Version 3.3 created 17 docx files in 2.807806968689 seconds As you can see phpdocx 5 is faster than phpdocx 3. Regards.

Posted by i-cre8  · 29-09-2015 - 07:01

Thank you, I have tested and although I don't get the blazing speeds you quote Version 5 is now a couple of seconds faster than Version 3. Thanks for your help.

Posted by admin  · 29-09-2015 - 07:25

Hello, The perfomance is thanks to the SSD we use on one of our test server. This type of hard disk improves a lot the speed of specific tasks. Regards.