diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3770ca..11df2973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ImageOptimize Changelog +## 1.4.30 - 2018.04.09 +### Added +* Added additional profiling information + ## 1.4.29 - 2018.04.06 ### Added * Added profiling to the image variant creation diff --git a/composer.json b/composer.json index 036c3cce..711882fe 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nystudio107/craft-imageoptimize", "description": "Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.", "type": "craft-plugin", - "version": "1.4.29", + "version": "1.4.30", "keywords": [ "craft", "cms", @@ -28,7 +28,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "craftcms/cms": "^3.0.0-RC12", + "craftcms/cms": "^3.0.0", "imgix/imgix-php": "^1.1.0", "ksubileau/color-thief-php": "^1.3", "mikehaertl/php-shellcommand": "~1.2" diff --git a/src/services/Optimize.php b/src/services/Optimize.php index e4ff8c07..8e84d0a0 100644 --- a/src/services/Optimize.php +++ b/src/services/Optimize.php @@ -53,6 +53,7 @@ class Optimize extends Component */ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event) { + Craft::beginProfile('handleGetAssetUrlEvent', __METHOD__); $url = null; $settings = ImageOptimize::$plugin->getSettings(); if ($settings->transformMethod != 'craft') { @@ -89,6 +90,7 @@ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event) ImageOptimize::$transformParams ); } + Craft::endProfile('handleGetAssetUrlEvent', __METHOD__); return $url; } @@ -102,6 +104,7 @@ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event) */ public function handleGenerateTransformEvent(GenerateTransformEvent $event) { + Craft::beginProfile('handleGenerateTransformEvent', __METHOD__); $tempPath = null; $settings = ImageOptimize::$plugin->getSettings(); @@ -152,6 +155,7 @@ public function handleGenerateTransformEvent(GenerateTransformEvent $event) $tempPath ); } + Craft::endProfile('handleGenerateTransformEvent', __METHOD__); return $tempPath; } @@ -200,6 +204,7 @@ public function saveTransformToTempFile(AssetTransformIndex $index, Image $image */ public function optimizeImage(AssetTransformIndex $index, string $tempPath) { + Craft::beginProfile('optimizeImage', __METHOD__); $settings = ImageOptimize::$plugin->getSettings(); // Get the active processors for the transform format $activeImageProcessors = $settings->activeImageProcessors; @@ -215,6 +220,7 @@ public function optimizeImage(AssetTransformIndex $index, string $tempPath) } } } + Craft::endProfile('optimizeImage', __METHOD__); } /** @@ -244,6 +250,7 @@ public function humanFileSize($bytes, $decimals = 1): string */ public function createImageVariants(AssetTransformIndex $index, Asset $asset, string $tempPath) { + Craft::beginProfile('createImageVariants', __METHOD__); $settings = ImageOptimize::$plugin->getSettings(); // Get the active image variant creators $activeImageVariantCreators = $settings->activeImageVariantCreators; @@ -304,6 +311,7 @@ public function createImageVariants(AssetTransformIndex $index, Asset $asset, st } } } + Craft::endProfile('createImageVariants', __METHOD__); } /** diff --git a/src/services/OptimizedImages.php b/src/services/OptimizedImages.php index a9a658e8..bf25b194 100644 --- a/src/services/OptimizedImages.php +++ b/src/services/OptimizedImages.php @@ -153,6 +153,7 @@ public function populateOptimizedImageModel(Asset $asset, $variants, OptimizedIm */ protected function generatePlaceholders(Asset $element, OptimizedImage $model, $aspectRatio) { + Craft::beginProfile('generatePlaceholders', __METHOD__); $settings = ImageOptimize::$plugin->getSettings(); if ($settings->generatePlaceholders && ImageOptimize::$generatePlaceholders) { $placeholder = ImageOptimize::$plugin->placeholder; @@ -177,6 +178,7 @@ protected function generatePlaceholders(Asset $element, OptimizedImage $model, $ @unlink($tempPath); } } + Craft::endProfile('generatePlaceholders', __METHOD__); } /** diff --git a/src/services/Placeholder.php b/src/services/Placeholder.php index 58b58b88..123cbbc3 100644 --- a/src/services/Placeholder.php +++ b/src/services/Placeholder.php @@ -80,6 +80,7 @@ public function generatePlaceholderBox($width, $height, $color = null) */ public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $position): string { + Craft::beginProfile('generatePlaceholderImage', __METHOD__); $result = ''; $width = self::PLACEHOLDER_WIDTH; $height = intval($width / $aspectRatio); @@ -88,6 +89,7 @@ public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $ $result = base64_encode(file_get_contents($placeholderPath)); unlink($placeholderPath); } + Craft::endProfile('generatePlaceholderImage', __METHOD__); return $result; } @@ -101,6 +103,7 @@ public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $ */ public function generateColorPalette(string $tempPath): array { + Craft::beginProfile('generateColorPalette', __METHOD__); $colorPalette = []; if (!empty($tempPath)) { // Extract the color palette @@ -110,6 +113,7 @@ public function generateColorPalette(string $tempPath): array $colorPalette[] = sprintf("#%02x%02x%02x", $colors[0], $colors[1], $colors[2]); } } + Craft::endProfile('generateColorPalette', __METHOD__); return $colorPalette; } @@ -123,6 +127,7 @@ public function generateColorPalette(string $tempPath): array */ public function generatePlaceholderSvg(string $tempPath): string { + Craft::beginProfile('generatePlaceholderSvg', __METHOD__); $result = ''; if (!empty($tempPath)) { @@ -151,7 +156,7 @@ public function generatePlaceholderSvg(string $tempPath): string } } } - + Craft::endProfile('generatePlaceholderSvg', __METHOD__); return $result; } @@ -168,9 +173,11 @@ public function generatePlaceholderSvg(string $tempPath): string */ public function createTempPlaceholderImage(Asset $asset, float $aspectRatio, $position): string { + Craft::beginProfile('createTempPlaceholderImage', __METHOD__); $width = self::TEMP_PLACEHOLDER_WIDTH; $height = intval($width / $aspectRatio); $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position); + Craft::endProfile('createTempPlaceholderImage', __METHOD__); return $tempPath; }