Exemple #1
0
fclose($f);
usort($funcs, 'func_compare');
$f = @fopen($argv[1], "r");
if (!$f) {
    die("Unable to open " . $argv[1]);
}
$count = 0;
$laststart = 0;
$lastaddr = 0;
$lastfunc = '';
while (($line = fgets($f)) !== false) {
    if ($line[0] == '[') {
        $lastaddr = hexdec(substr($line, 4, 8));
    } else {
        if (substr($line, 0, 6) == "\t\$time") {
            preg_match('/^\\s*\\$time\\(\\s*"iss",\\s*"clocks",\\s*(\\d+),\\s*"cycle",\\s*(\\d+)/', $line, $match);
            $func = funcname($funcs, $lastaddr);
            if ($lastfunc != '' && $func != $lastfunc) {
                printf("@%8d: %5d: %s\n", $laststart, $count, $lastfunc);
                $laststart = $match[2];
                $count = 0;
            }
            $lastfunc = $func;
            $count += $match[1];
        }
    }
}
if (!feof($f)) {
    die("Something went wrong");
}
fclose($f);
Exemple #2
0
<?

function funcname() {
  return "funcname";
}

function otherfuncname() {
  return "funcname";
}


$nm = funcname();
echo $nm() . "\n";

for ($i = 0; $i < 10000000; $i++) {
  $nm = $nm();
  if ($i % 100 == 0) {
    $nm = "otherfuncname";
  }
}

echo $nm() . "\n";

$pf="printf";
$pf("printf results: %12s\n", "mcguffin");