Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
z-push
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Björn Fischer
z-push
Commits
ab4f7cb5
Commit
ab4f7cb5
authored
Jan 27, 2016
by
Manfred Kutas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZP-781 Nicer format for memory usage.
Released under the Affero GNU General Public License (AGPL) version 3.
parent
989e8537
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
zlog.php
src/lib/core/zlog.php
+4
-1
utils.php
src/lib/utils/utils.php
+18
-0
No files found.
src/lib/core/zlog.php
View file @
ab4f7cb5
...
...
@@ -145,8 +145,11 @@ class ZLog {
else
{
$time_used
=
number_format
(
microtime
(
true
)
-
$_SERVER
[
"REQUEST_TIME_FLOAT"
],
4
);
}
$peakUsage
=
memory_get_peak_usage
(
false
);
$truePeakUsage
=
memory_get_peak_usage
(
true
);
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
sprintf
(
"Memory usage information: %s/%s - Execution time: %s - HTTP responde code: %s"
,
memory_get_peak_usage
(
false
),
memory_get_peak_usage
(
true
),
$time_used
,
http_response_code
()));
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
sprintf
(
"Memory usage information: %s/%s (%s B/%s B) - Execution time: %s - HTTP responde code: %s"
,
Utils
::
FormatBytes
(
$peakUsage
),
Utils
::
FormatBytes
(
$truePeakUsage
),
$peakUsage
,
$truePeakUsage
,
$time_used
,
http_response_code
()));
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
"-------- End"
);
}
}
...
...
src/lib/utils/utils.php
View file @
ab4f7cb5
...
...
@@ -950,6 +950,24 @@ class Utils {
return
$res
;
}
/**
* Format bytes to a more human readable value.
* @param int $bytes
* @param int $precision
*
* @access public
* @return void|string
*/
public
static
function
FormatBytes
(
$bytes
,
$precision
=
2
)
{
if
(
$bytes
<=
0
)
return
'0 B'
;
$units
=
array
(
'B'
,
'KiB'
,
'MiB'
,
'GiB'
,
'TiB'
,
'PiB'
,
'EiB'
,
'ZiB'
);
$base
=
log
(
$bytes
,
1024
);
$fBase
=
floor
(
$base
);
$pow
=
pow
(
1024
,
$base
-
$fBase
);
return
sprintf
(
"%.
{
$precision
}
f %s"
,
$pow
,
$units
[
$fBase
]);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment