From 103eff5bcdafdafdddf0e2744ed168352a6ec77c Mon Sep 17 00:00:00 2001 From: Gilles Dubuc Date: Tue, 14 Jul 2015 11:21:21 +0200 Subject: [PATCH] Record timing of thumbnail generation and store pull Bug: T105681 Change-Id: If2edf285dc47736abde957a117ac4b40716072aa --- thumb.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/thumb.php b/thumb.php index b530bb586e..0d0a15ebcf 100644 --- a/thumb.php +++ b/thumb.php @@ -298,12 +298,19 @@ function wfStreamThumb( array $params ) { $headers[] = 'Vary: ' . implode( ', ', $varyHeader ); } + $stats = RequestContext::getMain()->getStats(); + // Stream the file if it exists already... $thumbPath = $img->getThumbPath( $thumbName ); if ( $img->getRepo()->fileExists( $thumbPath ) ) { + $starttime = microtime( true ); $success = $img->getRepo()->streamFile( $thumbPath, $headers ); + $streamtime = microtime( true ) - $starttime; + if ( !$success ) { wfThumbError( 500, 'Could not stream the file' ); + } else { + $stats->timing( 'media.thumbnail.stream', $streamtime ); } return; } @@ -318,7 +325,9 @@ function wfStreamThumb( array $params ) { } // Actually generate a new thumbnail + $starttime = microtime( true ); list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath ); + $generatetime = microtime( true ) - $starttime; /** @var MediaTransformOutput|bool $thumb */ // Check for thumbnail generation errors... @@ -339,6 +348,8 @@ function wfStreamThumb( array $params ) { if ( $errorMsg !== false ) { wfThumbError( $errorCode, $errorMsg ); } else { + $stats->timing( 'media.thumbnail.generate', $generatetime ); + // Stream the file if there were no errors $success = $thumb->streamFile( $headers ); if ( !$success ) { -- 2.20.1