Ticket #23102: timing_code.diff
File timing_code.diff, 2.1 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
1852 1852 $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); 1853 1853 $posts = array_filter( $posts ); 1854 1854 1855 // Timing code start 1856 global $attachment_timing_array; 1857 1858 if ( ! empty( $attachment_timing_array ) ) { 1859 $count = count( $attachment_timing_array ); 1860 $avg_time = round( 1000 * array_sum( $attachment_timing_array ) / $count, 3 ); // (ms) 1861 $text = "Avg time " . $avg_time . " ms based on " . $count . " thumbnails or medium-sized images.\r\n"; 1862 file_put_contents( '../timing_dump.txt', $text , FILE_APPEND ); 1863 } 1864 // Timing code end 1865 1855 1866 wp_send_json_success( $posts ); 1856 1867 } 1857 1868 -
wp-includes/media.php
1393 1393 // We have the actual image size, but might need to further constrain it if content_width is narrower. 1394 1394 // This is not necessary for thumbnails and medium size. 1395 1395 if ( 'thumbnail' == $size || 'medium' == $size ) { 1396 // Timer start 1397 $time_start = microtime( true ); 1398 1399 /* Option 1: Original 3.5.0 code 1396 1400 $width = $size_meta['width']; 1397 1401 $height = $size_meta['height']; 1402 */ 1403 1404 /* Option 2: Proposed 3.5.1 code */ 1405 list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); 1406 1407 /* Option 3: Equivalent 3.4 code 1408 list( $img_src, $width, $height ) = image_downsize( $attachment->ID, $size ); 1409 */ 1410 1411 // Timer end 1412 $time_end = microtime( true ); 1413 global $attachment_timing_array; 1414 $attachment_timing_array[] = $time_end - $time_start; 1398 1415 } else { 1399 1416 list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); 1400 1417 }