andieje
asked on
Help speeding up documents made with tcppdf
Hi
I am creating a 30 odd page document in tcpdf and its takes 1 min 17secs. I presume this is because my page had lots of graohcs. Ive tried jpeg, png etc but to difference. I cant cache the document.
I like tcpdf but i need these pages created like lightening fasteven if I have to pay.
However a second investigation of the page shows the sql queries are really slow.
Is it a slow process to add graphics is tcpdf? If not it must be these dv queries to create the page
Any ideas much appreciated
Kind regards
I am creating a 30 odd page document in tcpdf and its takes 1 min 17secs. I presume this is because my page had lots of graohcs. Ive tried jpeg, png etc but to difference. I cant cache the document.
I like tcpdf but i need these pages created like lightening fasteven if I have to pay.
However a second investigation of the page shows the sql queries are really slow.
Is it a slow process to add graphics is tcpdf? If not it must be these dv queries to create the page
Any ideas much appreciated
Kind regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi, andieje: What's missing? I'll be glad to help, ~Ray
ASKER
Hi. The comment has now appeared.
What's the quickest way for generating pdf in php?
Thanks
What's the quickest way for generating pdf in php?
Thanks
What's the quickest way for generating pdf in php?The question missed the point. What you really want to find out is "Where is the script spending its time?" and once you know the answer to that question then go back to the "quickest way" part. I am almost 100% certain that it's not about generating a PDF. Whenever there is a performance problem in a web application it's caused by the I/O subsystem, since disk access is about 3 orders of magnitude slower than RAM memory access. In modern applications this is the database. That's why I recommended EXPLAIN SELECT.
One of our E-E colleagues has a good article about this subject.
https://www.experts-exchange.com/Database/MySQL/A_1250-3-Ways-to-Speed-Up-MySQL.html
ASKER
Ok. I do understand our logic . Im just kncking out quick questions sometimes before looking deeper.
Cross off the easy
Which makes me
Cross off the easy
Which makes me
ASKER
Just a quick thought - would adding multiple 2) small graphics cause a problem (im still going to follow up rays explain issue
Why not show us the code for the TCPDF creation process and show us your test data? I don't really understand "adding multiple 2) small graphics" but if I see the code and data, I can set up my own tests and take some measurements.
ASKER
Its a project i have been handed over and its butchered. Code and cut and paste from everyywhere. And i thnk there are dependeneies i cant distribute
However i cannot turn down generosity such as that. I will look
The prebious was typo - (20) small graphics was
Also the grphics are being resized and i dont know whether to just make a copy at the right size or if a pdf 'frame' can handle this quickly
I will find something i can send
Thanks lifesaver ray
However i cannot turn down generosity such as that. I will look
The prebious was typo - (20) small graphics was
Also the grphics are being resized and i dont know whether to just make a copy at the right size or if a pdf 'frame' can handle this quickly
I will find something i can send
Thanks lifesaver ray
ASKER
Ray - you know your wonderful stopwatch
does it give you an indivudual and cumulative total for each line of code. It would be nice to have to a diagnostic tool like that that shows where your code id dawdling
Im not 100% sure not being an 00 php programming
thanks
does it give you an indivudual and cumulative total for each line of code. It would be nice to have to a diagnostic tool like that that shows where your code id dawdling
Im not 100% sure not being an 00 php programming
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
or might this do ths job. I'll open a separate question if we are getting off track
The StopWatch class lets you start and stop timers anywhere you want in your code. When the script ends, you will get a readout of the timers. To use the class, just include it in your script (you can do that at the end of the script if you want to avoid cluttering the code too much). Put the start() and stop() method calls into the appropriate places. The code snippet shows an example of how to use it.
ASKER
Have ou any thoughts on this or is it just overkill compare to the stopwatch.
http://newrelic.com/sp/brand?utm_source=GOOG&utm_medium=adwords&utm_content=rpm&utm_campaign=RPM&utm_term=NewRelic&mpc=PS-GOOG-RPM-EN-SIGNUP-Europe-Brand-NewRelic-LP3&gclid=CjwKEAjw5NihBRCZmdLkuuTHyWYSJACtCY0JSRe30inseVihWFmKA4OqEBjkiROHvX_jN6hs6jyNqxoCCVPw_wcB
http://newrelic.com/sp/brand?utm_source=GOOG&utm_medium=adwords&utm_content=rpm&utm_campaign=RPM&utm_term=NewRelic&mpc=PS-GOOG-RPM-EN-SIGNUP-Europe-Brand-NewRelic-LP3&gclid=CjwKEAjw5NihBRCZmdLkuuTHyWYSJACtCY0JSRe30inseVihWFmKA4OqEBjkiROHvX_jN6hs6jyNqxoCCVPw_wcB
That's a great tool! And there are other monitors built into things like phpUnit, etc. A google search will turn up more. I think it comes down to what you want to achieve. The StopWatch will let you see what's slow, then we can have a dialog here that focuses on the slow part. Here's a minimalist example to show the essential moving parts. You can start() and stop() as many timers as you want.
http://iconoun.com/demo/temp_andieje.php
http://iconoun.com/demo/temp_andieje.php
<?php // demo/temp_andieje.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
echo '<pre>';
// SEE http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28531628.html#a40371250
$signal = 'About to sleep 5 seconds';
$sw = new Stopwatch();
$sw->start($signal);
sleep(5);
$sw->stop($signal);
// A SCRIPT TIMER FOR ALL OR PART OF A SCRIPT PHP 5+
// MAN PAGE http://php.net/manual/en/function.microtime.php
class StopWatch
{
protected $a; // START TIME
protected $s; // STATUS - IF RUNNING
protected $z; // STOP TIME
public function __construct()
{
$this->a = array();
$this->s = array();
$this->z = array();
}
// A METHOD TO PROVIDE A FINAL READOUT, IF NEEDED
public function __destruct()
{
$ret = $this->readout();
if (!$ret) return FALSE;
echo
__CLASS__
. '::'
. __FUNCTION__
. '() '
;
echo "<b>$ret</b>";
echo PHP_EOL;
}
// A METHOD TO REMOVE A TIMER
public function reset($name='TIMER')
{
// RESET ALL TIMERS
if ($name == 'TIMER')
{
$this->__construct();
}
else
{
unset($this->a[$name]);
unset($this->s[$name]);
unset($this->z[$name]);
}
}
// A METHOD TO CAPTURE THE START TIME
public function start($name='TIMER')
{
$this->a[$name] = microtime(TRUE);
$this->z[$name] = $this->a[$name];
$this->s[$name] = 'RUNNING';
}
// A METHOD TO CAPTURE THE END TIME
public function stop($name='TIMER')
{
$ret = NULL;
// STOP ALL THE TIMERS
if ($name == 'TIMER')
{
foreach ($this->a as $name => $start_time)
{
// IF THIS TIMER IS STILL RUNNING, STOP IT
if ($this->s[$name])
{
$this->s[$name] = FALSE;
$this->z[$name] = microtime(TRUE);
}
}
}
// STOP ONLY ONE OF THE TIMERS
else
{
if ($this->s[$name])
{
$this->s[$name] = FALSE;
$this->z[$name] = microtime(TRUE);
}
else
{
$ret .= "ERROR: CALL TO STOP() METHOD: '$name' IS NOT RUNNING";
}
}
// RETURN AN ERROR MESSAGE, IF ANY
return $ret;
}
// A METHOD TO READ OUT THE TIMER(S)
public function readout($name='TIMER', $dec=3, $m=1000, $t = 'ms', $eol=PHP_EOL)
{
$str = NULL;
// GET READOUTS FOR ALL THE TIMERS
if ($name == 'TIMER')
{
foreach ($this->a as $name => $start_time)
{
$str .= $name;
// IF THIS TIMER IS STILL RUNNING UPDATE THE END TIME
if ($this->s[$name])
{
$this->z[$name] = microtime(TRUE);
$str .= " RUNNING ";
}
else
{
$str .= " STOPPED ";
}
// RETURN A DISPLAY STRING
$lapse_time = $this->z[$name] - $start_time;
$lapse_msec = $lapse_time * $m;
$lapse_echo = number_format($lapse_msec, $dec);
$str .= " $lapse_echo $t";
$str .= $eol;
}
return $str;
}
// GET A READOUT FOR ONLY ONE TIMER
else
{
$str .= $name;
// IF THIS TIME IS STILL RUNNING, UPDATE THE END TIME
if ($this->s[$name])
{
$this->z[$name] = microtime(TRUE);
$str .= " RUNNING ";
}
else
{
$str .= " STOPPED ";
}
// RETURN A DISPLAY STRING
$lapse_time = $this->z[$name] - $this->a[$name];
$lapse_msec = $lapse_time * $m;
$lapse_echo = number_format($lapse_msec, $dec);
$str .= " $lapse_echo $t";
$str .= $eol;
return $str;
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER