-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[4.4] Invalid timings in debug plugin #35655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MacJoom
merged 45 commits into
joomla:4.4-dev
from
Denitz:_4.0]_Wrong_timings_in_debug_plugin
Sep 11, 2023
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
4e191ed
start
Denitz 9734bd5
phpcs fix
Denitz 685368d
docblock fix
Denitz 77e9418
docblocks fix
Denitz 69d7bb4
custom memory collector
Denitz d8e5286
cs fix
Denitz 8eded10
fix cs
Denitz 1bb0fe6
even more cs
Denitz ed1ff10
Update plugins/system/cache/cache.php
Denitz 3bc7922
Update plugins/system/debug/src/DataCollector/MemoryCollector.php
Denitz c6e7a8a
Update plugins/system/debug/src/DataCollector/MemoryCollector.php
Denitz d0a74f1
Update plugins/system/debug/src/DataCollector/ProfileCollector.php
Denitz 204f4ab
Update plugins/system/debug/src/DataCollector/ProfileCollector.php
Denitz 08e4b04
cs
Denitz a1d274a
cs
Denitz 14f7884
revert ProfileCollector constructor.
Denitz 031c3e7
Merge branch '4.1-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz d61018d
fix
Denitz a72a7d2
Merge branch '4.1-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 0ff9593
Merge branch '4.1-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz b49d4ed
Remove 'afterRespond' mark
Denitz d58a325
Merge branch '_4.0]_Wrong_timings_in_debug_plugin' of github.com:Deni…
Denitz 0cd14a7
Merge branch '4.1-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz ba57d16
Merge remote-tracking branch 'joomla/4.1-dev' into _4.0]_Wrong_timing…
Denitz 3f63817
fix
Denitz f53faae
Merge tag 'psr12anchor' into psr12/merge/35655
joomla-bot 5858c86
Phase 1 convert BRANCH to PSR-12
joomla-bot 9ad58a5
Phase 2 convert BRANCH to PSR-12
joomla-bot b550afe
Merge tag 'psr12final' into psr12/merge/35655
joomla-bot b5f705b
Merge branch '4.2-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 8f70e54
Merge remote-tracking branch 'joomla/4.3-dev' into _4.0]_Wrong_timing…
Denitz 2c6d66d
fix
Denitz 62b6185
Merge branch '4.3-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 2c79078
fix CS
Denitz ede994c
Merge branch '4.3-dev' into _4.0]_Wrong_timings_in_debug_plugin
laoneo 91dddba
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 2c1373f
fix
Denitz f0241da
short Event, try to re-start drone
Denitz 48be548
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
laoneo 18ca831
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 880d983
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
laoneo aa4cd73
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
Denitz 6a5d9ea
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
MacJoom d190f10
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
MacJoom 31f19d4
Merge branch '4.4-dev' into _4.0]_Wrong_timings_in_debug_plugin
MacJoom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
plugins/system/debug/src/DataCollector/MemoryCollector.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @package Joomla.Plugin | ||
| * @subpackage System.Debug | ||
| * | ||
| * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\Plugin\System\Debug\DataCollector; | ||
|
|
||
| use Joomla\Plugin\System\Debug\AbstractDataCollector; | ||
| use Joomla\Registry\Registry; | ||
|
|
||
| // phpcs:disable PSR1.Files.SideEffects | ||
| \defined('_JEXEC') or die; | ||
| // phpcs:enable PSR1.Files.SideEffects | ||
|
|
||
| /** | ||
| * Collects info about the request duration as well as providing | ||
| * a way to log duration of any operations | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class MemoryCollector extends AbstractDataCollector | ||
| { | ||
| /** | ||
| * @var boolean | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected $realUsage = false; | ||
|
|
||
| /** | ||
| * @var float | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected $peakUsage = 0; | ||
|
|
||
| /** | ||
| * @param Registry $params Parameters. | ||
| * @param float $peakUsage | ||
| * @param boolean $realUsage | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function __construct(Registry $params, $peakUsage = null, $realUsage = null) | ||
| { | ||
| parent::__construct($params); | ||
|
|
||
| if ($peakUsage !== null) { | ||
| $this->peakUsage = $peakUsage; | ||
| } | ||
|
|
||
| if ($realUsage !== null) { | ||
| $this->realUsage = $realUsage; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether total allocated memory page size is used instead of actual used memory size | ||
| * by the application. See $real_usage parameter on memory_get_peak_usage for details. | ||
| * | ||
| * @return boolean | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getRealUsage() | ||
| { | ||
| return $this->realUsage; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether total allocated memory page size is used instead of actual used memory size | ||
| * by the application. See $real_usage parameter on memory_get_peak_usage for details. | ||
| * | ||
| * @param boolean $realUsage | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function setRealUsage($realUsage) | ||
| { | ||
| $this->realUsage = $realUsage; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the peak memory usage | ||
| * | ||
| * @return integer | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getPeakUsage() | ||
| { | ||
| return $this->peakUsage; | ||
| } | ||
|
|
||
| /** | ||
| * Updates the peak memory usage value | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function updatePeakUsage() | ||
| { | ||
| if ($this->peakUsage === null) { | ||
| $this->peakUsage = memory_get_peak_usage($this->realUsage); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return array | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function collect() | ||
| { | ||
| $this->updatePeakUsage(); | ||
|
|
||
| return [ | ||
| 'peak_usage' => $this->peakUsage, | ||
| 'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage, 3), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getName() | ||
| { | ||
| return 'memory'; | ||
| } | ||
|
|
||
| /** | ||
| * @return array | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getWidgets() | ||
| { | ||
| return [ | ||
| 'memory' => [ | ||
| 'icon' => 'cogs', | ||
| 'tooltip' => 'Memory Usage', | ||
| 'map' => 'memory.peak_usage_str', | ||
| 'default' => "'0B'", | ||
| ], | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.