logo       

CVS: phpwiki/tests/unit test.php,1.35,1.36: msg#00147

web.wiki.phpwiki.checkins

Subject: CVS: phpwiki/tests/unit test.php,1.35,1.36

Update of /cvsroot/phpwiki/phpwiki/tests/unit
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31374/tests/unit

Modified Files:
test.php
Log Message:
add getMemoryUsage to stdlib

Index: test.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/tests/unit/test.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -2 -b -p -d -r1.35 -r1.36
--- test.php 21 Jan 2005 11:22:39 -0000 1.35
+++ test.php 25 Jan 2005 07:10:51 -0000 1.36
@@ -102,30 +102,9 @@ function printMemoryUsage($msg = '') {
echo "-- MEMORY USAGE: ";
$oldmem = $mem;
- if (function_exists('memory_get_usage') and memory_get_usage()) {
- $mem = memory_get_usage();
- // } elseif (function_exists('getrusage') and ($u =
getrusage()) and !empty($u['ru_maxrss'])) {
- // $mem = $u['ru_maxrss'];
- } elseif (substr(PHP_OS,0,3)=='WIN') { // requires a newer cygwin
- // what we want is the process memory only: apache or php
- $pid = getmypid();
- // This works only if it's a cygwin process (apache or php)
- //$mem = (integer) trim(system("cat /proc/$pid/statm |cut -f1"));
- // if it's native windows use something like this:
- // (requires pslist from sysinternals.com)
- $memstr = system("pslist $pid|grep -A1 Mem|sed 1d|perl -ane\"print
\$"."F[5]\"");
- $mem = (integer) trim($memstr);
- } else {
- $pid = getmypid();
- //%MEM: Percentage of total memory in use by this process
- //VSZ: Total virtual memory size, in 1K blocks.
- //RSS: Real Set Size, the actual amount of physical memory
allocated to this process.
- //CPU time used by process since it started.
- //echo "%",`ps -o%mem,vsz,rss,time -p $pid|sed 1d`,"\n";
- $memstr = system("ps -orss -p $pid|sed 1d");
- $mem = (integer) trim($memstr);
- }
+ $mem = getMemoryUsage();
if (!$initmem) $initmem = $mem;
// old libc on sf.net server doesn't understand "%+4d"
- echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" :
($mem == $oldmem ? " " : ""), $mem - $oldmem, $mem - $initmem);
+ echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" :
($mem == $oldmem ? " " : ""),
+ $mem - $oldmem, $mem - $initmem);
// TODO: print time
flush();



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise