As posted earlier, we are still using STP and are facing performance problems on some large forms( over 8000 elements in XSM). We are using SM 2.4.1 on PHP 4.3.x, Apache 1.3.x
We profiled the code and most of the time is spent in smSmartForm::runTemplate. On further investigation, some of the preg match calls were consuming most of the time within this function. We were not clear on why this was done. We came up with a lame solution of commenting out some of the offending code, which in our opinion was not doing much in terms of functionality, but were killing the CPU. With the modified code, we were able to get orders of magnitude performance improvement in all the machines tested.
Our question is, are we on the right track? Could you please elaborate on the functionality of lines commented out. May be it's for a special case, which is not relevant for us. I am enclosing the modified code of runtemplate function below.
function runTemplate() {
// BACKWARD COMPATIBILITY
// FIXME: this is deprecated, will be removed at some point...
if (is_string($this->template)) {
// loop through each entity, do subs
foreach ($this->entityList as $ent) {
// get info from entity objects for display
$vName = $ent->varName;
//the following line commented
//(preg_match("/^(.+)\_\w+$/",$vName,$m)) ? $vpName = $m[1] : $vpName = $vName;
$title = $ent->getTitle();
$input = $ent->output();
// try to substitute in the template
$tSubVar = '{'."$vName.title".'}';
//next line commented
//$tpSubVar = '{'."$vpName.title".'}';
$iSubVar = '{'."$vName.input".'}';
//next line commented
//$ipSubVar = '{'."$vpName.input".'}';
As posted earlier, we are still using STP and are facing performance problems on some large forms( over 8000 elements in XSM). We are using SM 2.4.1 on PHP 4.3.x, Apache 1.3.x
We profiled the code and most of the time is spent in smSmartForm::runTemplate. On further investigation, some of the preg match calls were consuming most of the time within this function. We were not clear on why this was done. We came up with a lame solution of commenting out some of the offending code, which in our opinion was not doing much in terms of functionality, but were killing the CPU. With the modified code, we were able to get orders of magnitude performance improvement in all the machines tested.
Our question is, are we on the right track? Could you please elaborate on the functionality of lines commented out. May be it's for a special case, which is not relevant for us. I am enclosing the modified code of runtemplate function below.
function runTemplate() {
// BACKWARD COMPATIBILITY
// FIXME: this is deprecated, will be removed at some point...
if (is_string($this->template)) {
// loop through each entity, do subs
foreach ($this->entityList as $ent) {
// get info from entity objects for display
$vName = $ent->varName;
//the following line commented
//(preg_match("/^(.+)\_\w+$/",$vName,$m)) ? $vpName = $m[1] : $vpName = $vName;
$title = $ent->getTitle();
$input = $ent->output();
// try to substitute in the template
$tSubVar = '{'."$vName.title".'}';
//next line commented
//$tpSubVar = '{'."$vpName.title".'}';
$iSubVar = '{'."$vName.input".'}';
//next line commented
//$ipSubVar = '{'."$vpName.input".'}';
$this->template = str_replace($tSubVar, $title, $this->template);
//next line commented
//$this->template = str_replace($tpSubVar, $title, $this->template);
$this->template = str_replace($iSubVar, $input, $this->template);
//next line commented
//$this->template = str_replace($ipSubVar, $input, $this->template);
}
//rest of the code untouched...
....
}
Thanks in advance