Forum How do I...?

Performance degradation when upgrading to r8 PHP wrapper

jprateragg
I don't know what version of the PHP wrapper we're currently using--it says it was last modified March 15, 2012. I just decided to upgrade to the r8 version of the wrapper. I noticed the conversion time about doubled from the previous version to the newest version. I'm using the convert_file_to_passthru method on a query-intensive page. When viewing just the page to be converted, it takes about 5 seconds for the page to generate--but when using the latest wrapper, it doubles the time required for viewing. Just wondering if I've done something wrong of there's a possible bug. When viewing task manager, I noticed the CPU on the database server was staying high twice as long when using the previous wrapper--it almost seems like it's trying to generate the page twice. I'm using PrinceXML 8.1 R3 on Windows.
mikeday
Just to make sure, can you change the speed back and forth simply by swapping the PHP wrapper file, so it definitely isn't caused by running a different version of Prince?
jprateragg
I've been running the same version of Prince for several weeks. It was only when I swapped out the wrapper that I noticed the speed degradation. So yes, it's definitely being caused by simply swapping out the wrapper.
mikeday
Okay, that's very strange. The only differences between r7 and r8 for the PHP wrapper are adding double quotes around the prince.exe path, and the addition of some extra methods. Certainly nothing that you would expect to double the time. Could you try commenting out the call to addDoubleQuotes() anyway, and see if that changes anything?
conner_bw
Not really performance related but I thought I would mention it here since it's a thread about the r8 PHP wrapper.

I upgraded from R7 to R8 of this PHP wrapper today. I noticed:

PHP Notice:  Undefined property: Prince::$InputType in /path/to/prince.php on line 412


PHP is case sensitive. You need to change.
$this->InputType . '" ';


To:
$this->inputType . '" ';


Without this change, the logs bomb, possibly dumping errors into the PHP output buffer.

While I'm here there are a couple other errors in this file, if you want a patched version I can send it to you.

$cmdline .= '--fileroot="' + $this->fileRoot . '" ';


Wrong concatenation, + is for JavaScript while . is for PHP.

$outputStr .=  chr(34) . substr($str, $spaceStart, $numSpaces) . chr(34);


$spaceStart is never declared, needs to be set to `$spaceStart = 0` with the others above or this can bomb.

Regards,
mikeday
Red faces all round! We will fix these issues, thanks for letting us know. :oops:
mikeday
Today we have released an updated PHP wrapper for Prince that fixes the errors, thanks again for letting us know.