View Issue Details

IDProjectCategoryView StatusLast Update
0000175XdebugProfilingpublic2021-04-14 16:10
ReporterGoodStuff Assigned Toderick  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionunable to reproduce 
PlatformPHP 5.1.2OSWindows XPOS VersionSP1
Product Version2.0.0dev 
Target Version2.2dev 
Summary0000175: Profile: function or class definition has no entry in profile, and adds to self time in wrong place
Description

While profiling my app, I noticed something odd in the "self" times of some of my scripts.

Let's say file A require_once() file B. File B require_once() file C. File C has a lot of function or class definitions.

In the profiler, no "events" are logged for C.php. Also, almost no time is assigned to C.php, but a lot of time is (incorrectly) assigned to the "self" time of B.php.

Steps To Reproduce

Profile A.php and examine the cachegrind output.

(a.php, b.php, c.php and example cachegrind output atached in zip)

TagsNo tags attached.
Operating SystemWindows XP
PHP Version5.1.2

Activities

GoodStuff

2006-04-20 16:35

reporter   ~0000386

Sorry, was no way to attach zip. Here are example files:

a.php:
"""
<?php
require_once("b.php");
?>
<html>
<body>
qzna!
</body>
</html>
"""

b.php
"""
<?php
require_once("c.php");
?>
"""

c.php
"""
<?php

function a()
{
Header("Content-type: text/html");
Header("Cache-Control: no-cache, must-revalidate");
Header("Pragma: no-cache");
}

function b($a,$b)
{
    echo &quot;&lt;a href=\&quot;$a\&quot;>$b&lt;/a>&quot;;
}

function c($input)
{
$input = str_replace(array("&","""), array("&","'"), $input);
$input = htmlspecialchars($input);
$output = "";

  for ($i=0;$i&lt;strlen($input);$i++)
  {
     $c = $input{$i};

     if (ord($c) > 127)
    {
        $output .= &quot;&#&quot; . ord($c) . &quot;;&quot;;
     }
    elseif ($c == &quot;$&quot;)
    {
        $output .= &quot;$$&quot;;
    }
    else
    {
        $output .= $c;
     }
  }

  return $output;

}

function d($input)
{
$output = "";

  for ($i=0;$i&lt;strlen($input);$i++)
  {
     if (ereg(&quot;[[:alnum:]., '()?-]&quot;,$input{$i}))
    {
        $output .= $input{$i};
     }
  }

  return $output;

}

function br()
{
return "<br />\n";
}

function e($name, $value, $options)
{
$element = "<select name=\"$name\" value=\"$value\">\n";

   while (list($key, $val) = each($options))
   {
       $element .= &quot;    &lt;option value=\&quot;$key\&quot;>$val&lt;/option>\n&quot;;
   }

   $element .= &quot;&lt;/select>&quot;;

   return $element;

}

function f($text, $key, $value=NULL)
{
if ($value === NULL)
{
return "$text<input name=\"$key\"/>";
}
else
{
return "$text<input name=\"$key\" value=\"$value\"/>";
}
}

function g($text, $img = "")
{

 if (isset($_SESSION['user']))
 {
     $dir = $_SESSION['user']->theme;
     $display = ($dir != &quot;off&quot; and $dir != &quot;&quot;);
 }
 else
 {
     $dir = &quot;default&quot;;
     $display = true;
 }

  if ($img == &quot;&quot;)
    $img = strtolower($text);

  if ($display)
      return &quot;&lt;img alt=\&quot;$text\&quot; src=\&quot;./theme/$dir/$img.gif\&quot;/>&quot;;
  else
      return &quot;$text&quot;;

}

function h($url, $text, $postfield = NULL, $setvar = NULL, $method = "get")
{
$element = "";

   if ($method == &quot;get&quot;)
   {
       if ($setvar === NULL)
       {
           $element .= &quot;&lt;a href=\&quot;$url&quot;;

           if ($postfield !== NULL)
           {
               $first = true;
               reset($postfield);
               while (list($key, $val) = each($postfield))
               {
                   if ($first)
                   {
                       $first = false;
                       $element .= &quot;?&quot;;
                   }
                   else
                   {
                       $element .= &quot;&&quot;;
                   }
                   $element .= &quot;$key=$val&quot;;
               }
           }

           $element .= &quot;\&quot;>$text&lt;/a>&quot;;
       }
       else
       {
           $element .= &quot;&lt;anchor>$text&lt;go href=\&quot;$url&quot;;

           if (trim(session_id())!=&quot;&quot; AND trim(session_id())!=&quot;deleted&quot;)
               $postfield[&quot;PHPSESSID&quot;] = session_id();

           if ($postfield !== NULL)
           {
               $first = true;
               reset($postfield);
               while (list($key, $val) = each($postfield))
               {
                   if ($first)
                   {
                       $first = false;
                       $element .= &quot;?&quot;;
                   }
                   else
                   {
                       $element .= &quot;&&quot;;
                   }
                   $element .= &quot;$key=$val&quot;;
               }
           }

           $element .= &quot;\&quot; method=\&quot;get\&quot;>\n&quot;;

           reset($setvar);
           while (list($key, $val) = each($setvar))
           {
               $element .= &quot;   &lt;setvar name=\&quot;$key\&quot; value=\&quot;$val\&quot;/>\n&quot;;
           }

           $element .= &quot;&lt;/go>&lt;/anchor>&quot;;
       }
   }
   elseif ($method = &quot;post&quot;)
   {
       if ($setvar === NULL)
       {
           if (trim(session_id())!=&quot;&quot; AND trim(session_id())!=&quot;deleted&quot;)
               $postfield[&quot;PHPSESSID&quot;] = session_id();

           if ($postfield === NULL)
           {
               $element .= &quot;&lt;a href=\&quot;$url\&quot;>$text&lt;/a>&quot;;
           }
           else
           {
               $element .= &quot;&lt;anchor>$text&lt;go href=\&quot;$url\&quot; method=\&quot;post\&quot;>\n&quot;;

               reset($postfield);
               while (list($key, $val) = each($postfield))
               {
                   $element .= &quot;   &lt;postfield name=\&quot;$key\&quot; value=\&quot;$val\&quot;/>\n&quot;;
               }

               $element .= &quot;&lt;/go>&lt;/anchor>&quot;;
           }
       }
       else
       {
           $element .= &quot;&lt;anchor>$text&lt;go href=\&quot;$url\&quot; method=\&quot;post\&quot;>\n&quot;;

           if (trim(session_id())!=&quot;&quot; AND trim(session_id())!=&quot;deleted&quot;)
               $postfield[&quot;PHPSESSID&quot;] = session_id();

           reset($postfield);
           while (list($key, $val) = each($postfield))
           {
               $element .= &quot;   &lt;postfield name=\&quot;$key\&quot; value=\&quot;$val\&quot;/>\n&quot;;
           }

           reset($setvar);
           while (list($key, $val) = each($setvar))
           {
               $element .= &quot;   &lt;setvar name=\&quot;$key\&quot; value=\&quot;$val\&quot;/>\n&quot;;
           }

           $element .= &quot;&lt;/go>&lt;/anchor>&quot;;
       }
   }

   return $element;

}

function i($code, $heading, $feed)
{
echo g("headlines.php",$heading,array("code"=>$code,"feed"=>$feed),NULL,"post") . br();
}

function j($haystack, $char_list)
{
if (!is_scalar($haystack)) {
user_error('strpbrk() expects parameter 1 to be string, ' .
gettype($haystack) . ' given', E_USER_WARNING);
return false;
}

    if (!is_scalar($char_list)) {
        user_error('strpbrk() expects parameter 2 to be scalar, ' .
            gettype($needle) . ' given', E_USER_WARNING);
        return false;
    }

    $haystack  = (string) $haystack;
    $char_list = (string) $char_list;

    $len = strlen($haystack);
    for ($i = 0; $i &lt; $len; $i++) {
        $char = substr($haystack, $i, 1);
        if (strpos($char_list, $char) === false) {
            continue;
        }
        return substr($haystack, $i);
    }

    return false;

}

?>
"""

cachegrind.out.1398746969:
"""
version: 0.9.6
cmd: C:\Inetpub\waproot\test\a.php
part: 1

events: Time

fl=C:\Inetpub\waproot\test\c.php
fn=require_once::C:\Inetpub\waproot\test\c.php
1 240

fl=C:\Inetpub\waproot\test\b.php
fn=require_once::C:\Inetpub\waproot\test\b.php
1 19378
cfn=require_once::C:\Inetpub\waproot\test\c.php
calls=1 0 0
2 240

fl=C:\Inetpub\waproot\test\a.php
fn={main}

summary: 25269

0 5650
cfn=require_once::C:\Inetpub\waproot\test\b.php
calls=1 0 0
2 19619

"""

derick

2021-03-17 09:39

administrator   ~0005770

Is this issue still relevant to you?

derick

2021-04-14 16:10

administrator   ~0005844

Closing this, as it is missing requested feedback.

Issue History

Date Modified Username Field Change
2006-04-20 16:32 GoodStuff New Issue
2006-04-20 16:35 GoodStuff Note Added: 0000386
2010-03-20 23:47 derick Target Version => 2.2dev
2016-07-31 12:35 derick Category Debug client (console) => debugclient (debugging tool)
2016-07-31 12:35 derick Category debugclient (debugging tool) => (No Category)
2016-08-02 18:46 derick Category (No Category) => Profiling
2016-12-04 16:26 derick Assigned To => derick
2016-12-04 16:26 derick Status new => acknowledged
2021-03-17 09:39 derick Status acknowledged => feedback
2021-03-17 09:39 derick Note Added: 0005770
2021-04-14 16:10 derick Status feedback => closed
2021-04-14 16:10 derick Resolution open => unable to reproduce
2021-04-14 16:10 derick Note Added: 0005844