/inc/prof.inc.php (751d651bf5a5b892ad83512af40b3f95fb70eb83) (3887 bytes) (mode 100644) (type blob)
<?php
// Profiling functions
$rg_prof_main = array();
$rg_prof_state = array();
$rg_prof_tmp = array();
/*
* This will be called by submodules like git and db
*/
function rg_prof_set($data)
{
global $rg_prof_state;
foreach ($data as $k => $v) {
if (isset($rg_prof_state[$k]))
$rg_prof_state[$k] += $v;
else
$rg_prof_state[$k] = $v;
}
}
function rg_prof_start($label)
{
global $peak0;
global $rg_prof_tmp;
global $rg_prof_state;
if (isset($rg_prof_tmp[$label])) {
// Nested func call
$rg_prof_tmp[$label]['level']++;
$rg_prof_tmp[$label]['runs']++;
} else {
$mem = memory_get_peak_usage() - $peak0;
$rg_prof_tmp[$label] = $rg_prof_state;
$rg_prof_tmp[$label]['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
$rg_prof_tmp[$label]['mem'] = intval($mem / 1024);
$rg_prof_tmp[$label]['level'] = 1;
$rg_prof_tmp[$label]['runs'] = 1;
}
}
function rg_prof_end($label)
{
global $peak0;
global $rg_prof_tmp;
global $rg_prof_state;
global $rg_prof_main;
if (!isset($rg_prof_tmp[$label])) {
rg_internal_error("rg_prof_start was not called for label [$label]!");
return;
}
// We are in a recursive call, do not record info in this case
$rg_prof_tmp[$label]['level']--;
if ($rg_prof_tmp[$label]['level'] > 0)
return;
$start = $rg_prof_tmp[$label];
$mem = memory_get_peak_usage() - $peak0;
$c = $rg_prof_state;
$c['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
$c['runs'] = $start['runs']; $start['runs'] = 0;
$c['mem'] = intval($mem / 1024);
$c['level'] = 0; // just to not complain that is not defined
// we substract what was before start
foreach ($start as $key => $val)
$c[$key] -= $val;
// add to main label
if (!isset($rg_prof_main[$label])) {
$rg_prof_main[$label] = $c;
} else {
foreach ($c as $key => $val) {
// we may have items that are present at "end" time
// and not at "start" time
if (!isset($rg_prof_main[$label][$key]))
$rg_prof_main[$label][$key] = $val;
else
$rg_prof_main[$label][$key] += $val;
}
}
unset($rg_prof_tmp[$label]);
}
function rg_prof_get()
{
global $rg_prof_main;
return $rg_prof_main;
}
function rg_prof_html()
{
global $rg_prof_main;
// get all possible variables
$vars = array();
foreach ($rg_prof_main as $label => $per_label)
foreach ($per_label as $k => $v)
$vars[$k] = 1;
$ret = "<table>";
$ret .= "<tr>";
$ret .= "<td>Label</td>";
foreach ($vars as $var => $junk)
$ret .= "<td>" . $var . "</td>";
$ret .= "</tr>";
foreach ($rg_prof_main as $label => $per_label) {
$ret .= "<tr>";
$ret .= "<td>" . $label . "</td>";
foreach ($vars as $k => $junk) {
if (!isset($per_label[$k]))
$v = 0;
else
$v = $per_label[$k];
$ret .= "<td>" . $v . "</td>";
}
$ret .= "</tr>";
}
$ret .= "</table>\n";
return $ret;
}
function rg_prof_sort($a, $b)
{
if (!isset($a['time_ms']))
return 1;
if (!isset($b['time_ms']))
return 1;
return $a['time_ms'] > $b['time_ms'];
}
function rg_prof_text()
{
global $rg_prof_main;
$ret = "";
// get all possible variables
$vars = array();
foreach ($rg_prof_main as $label => $per_label)
foreach ($per_label as $k => $v)
$vars[$k] = 1;
unset($vars['level']);
// sort by time_ms
uasort($rg_prof_main, "rg_prof_sort");
$ret .= str_pad("Profiling:", 22, ' ');
foreach ($vars as $k => $v)
$ret .= "\t" . $k;
$ret .= "\n";
$add = "";
foreach ($rg_prof_main as $label => $per_label) {
if (($per_label['time_ms'] < 5) && ($per_label['mem'] < 20))
continue;
$ret .= $add;
$add = "\n";
$ret .= str_pad($label, 22, ' ');
foreach ($vars as $k => $junk) {
if (!isset($per_label[$k]))
$v = 0;
else
$v = $per_label[$k];
$ret .= "\t$v";
}
}
return $ret;
}
function rg_prof_log()
{
$p = rg_prof_text();
rg_log_ml($p);
rg_log("peak: " . sprintf("%.2f MiB", memory_get_peak_usage(TRUE) / 1024 / 1024));
}
?>
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
9 |
f3c7a7c5da68804a1bdf391127ba34aed33c3cca |
.exclude |
100644 |
blob |
102 |
eaeb7d777062c60a55cdd4b5734902cdf6e1790c |
.gitignore |
100644 |
blob |
289 |
fabbff669e768c05d6cfab4d9aeb651bf623e174 |
AUTHORS |
100644 |
blob |
1132 |
dd65951315f3de6d52d52a82fca59889d1d95187 |
Certs.txt |
100644 |
blob |
549 |
41c3bdbba8ec2523fe24b84bdd46777fc13e8345 |
History.txt |
100644 |
blob |
34520 |
dba13ed2ddf783ee8118c6a581dbf75305f816a3 |
LICENSE |
100644 |
blob |
3398 |
cf75b360b8a3e6ef86bc4a42648e353bd58c2a80 |
Makefile.in |
100644 |
blob |
5774 |
4a18249bf06d04d1e27d97623f12a7a2d51f83c0 |
README |
100644 |
blob |
118763 |
259c7b1871cb204da34bc36f9b635efb208c8a40 |
TODO |
100644 |
blob |
1294 |
f22911eb777f0695fcf81ad686eac133eb11fcc4 |
TODO-plans |
100644 |
blob |
203 |
a2863c67c3da44126b61a15a6f09738c25e0fbe0 |
TODO.perf |
100644 |
blob |
1044 |
9bb3652b3937eb624dba0f2d8efff7ce6c0ce0e2 |
TODO.vm |
040000 |
tree |
- |
21928e906ad2907a55c2e81c2a8b0502b586b8a0 |
artwork |
100644 |
blob |
4650 |
548f8c18609fa92b720aebfa5433f50a2c4ced78 |
compare.csv |
100755 |
blob |
30 |
92c4bc48245c00408cd7e1fd89bc1a03058f4ce4 |
configure |
040000 |
tree |
- |
69114e8648f8e0e7173c76e30ca6bbfcece7df31 |
debian |
040000 |
tree |
- |
afac05b52ba7b5cd8de8a5141ab143b01cad8e46 |
docker |
040000 |
tree |
- |
f67d3605efbd6422a8acdd953578991139266391 |
docs |
100755 |
blob |
16720 |
52405deef0d3708e7553022e1e9db73faa28d05c |
duilder |
100644 |
blob |
536 |
96c75f943c5bf93b54dbddf678e8a99d7ba4ff93 |
duilder.conf |
040000 |
tree |
- |
c503cf29ce2337a771fdfdbf4225b35d8e81ab98 |
hooks |
040000 |
tree |
- |
dddbdd6b3e3f98f12622b28a544c5e05febe1d24 |
inc |
040000 |
tree |
- |
ab5cc695f620de9abecc84af49866a45612067c6 |
misc |
100644 |
blob |
3742 |
1d19fcac5abc96f5aa3412ee9ee4e7f0dfe0bc08 |
rocketgit.spec.in |
040000 |
tree |
- |
1b971d1b8f26cf4a14ee7ab74006cd4285e99ed6 |
root |
040000 |
tree |
- |
edfd5fcdabcb2a987269d8167dfe8d02eebe3e19 |
samples |
040000 |
tree |
- |
a2ceaf5273e4bd4d74691afae72ec570de83a3c0 |
scripts |
040000 |
tree |
- |
00c52dce99b99f5f59800512ffd8e145d5ffe2c9 |
selinux |
100755 |
blob |
256 |
462ccd108c431f54e380cdac2329129875a318b5 |
spell_check.sh |
040000 |
tree |
- |
cb54e074b3ca35943edfcda9dd9cfcd281bcd9e7 |
techdocs |
040000 |
tree |
- |
5b464ef56a79806751442be1ddd01681571cd7fd |
tests |
040000 |
tree |
- |
63f68e921ac8d6a62ea9c3d180e072c7c4725b7d |
tools |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit
Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main