Committing live hacks: additional profiling points
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 17 Aug 2005 20:04:39 +0000 (20:04 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 17 Aug 2005 20:04:39 +0000 (20:04 +0000)
includes/Image.php
thumb.php

index a741aab..18449a1 100644 (file)
@@ -915,6 +915,9 @@ class Image
        function renderThumb( $width, $useScript = true ) {
                global $wgUseSquid, $wgInternalServer;
                global $wgThumbnailScriptPath, $wgSharedThumbnailScriptPath;
+
+               $fname = 'Image::renderThumb';
+               wfProfileIn( $fname );
                
                $width = intval( $width );
 
@@ -922,18 +925,22 @@ class Image
                if ( ! $this->exists() )
                {
                        # If there is no image, there will be no thumbnail
+                       wfProfileOut( $fname );
                        return null;
                }
                
                # Sanity check $width
                if( $width <= 0 || $this->width <= 0) {
                        # BZZZT
+                       wfProfileOut( $fname );
                        return null;
                }
 
                if( $width >= $this->width && !$this->mustRender() ) {
                        # Don't make an image bigger than the source
-                       return new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() );
+                       $thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() );
+                       wfProfileOut( $fname );
+                       return $thumb;
                }
                
                $height = floor( $this->height * ( $width/$this->width ) );
@@ -941,7 +948,9 @@ class Image
                list( $isScriptUrl, $url ) = $this->thumbUrl( $width );
                if ( $isScriptUrl && $useScript ) {
                        // Use thumb.php to render the image
-                       return new ThumbnailImage( $url, $width, $height );
+                       $thumb = new ThumbnailImage( $url, $width, $height );
+                       wfProfileOut( $fname );
+                       return $thumb;
                }
 
                $thumbName = $this->thumbName( $width, $this->fromSharedDirectory );
@@ -976,7 +985,9 @@ class Image
                        }
                }
                
-               return new ThumbnailImage( $url, $width, $height, $thumbPath );
+               $thumb = new ThumbnailImage( $url, $width, $height, $thumbPath );
+               wfProfileOut( $fname );
+               return $thumb;
        } // END OF function renderThumb
 
        /**
index ff84d89..0183c3f 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -51,6 +51,7 @@ if ( file_exists( $thumbPath ) && filemtime( $thumbPath ) >= filemtime( $imagePa
 
 // OK, no valid thumbnail, time to get out the heavy machinery
 require_once( 'Setup.php' );
+wfProfileIn( 'thumb.php' );
 
 $img = Image::newFromName( $fileName );
 if ( $img ) {
@@ -72,5 +73,7 @@ if ( $thumb && $thumb->path ) {
 </body></html>";
 }
 
+wfProfileOut( 'thumb.php' );
+
 
 ?>