[TYPO3-performance] TS-Rendering - IMG_RESOURCE - 622 ms - Solution

Rupert Germann rupi at gmx.li
Mon Sep 28 16:34:25 CEST 2009


hey,

thanks masi for pointing me to this thread.
I did some benchmarks comparing execution times for md5_file() and 
filemtime()+filemsize() for different filesizes. the results for a call 
to getCachedImageDimensions() with either md5_file or filemtime+filesize 
are listed, too.


11 MB file:
md5_file			41.085 ms
getCachedImageDimensions	41.559 ms

filemtime, filesize		0.007 ms
getCachedImageDimensions	0.377 ms
--------------------------------------------
200 KB file:
md5_file			1.025 ms
getCachedImageDimensions	1.068 ms

filemtime, filesize		0.006 ms
getCachedImageDimensions	0.171 ms
--------------------------------------------
10 KB file:
md5_file			0.064 ms
getCachedImageDimensions	0.167 ms

filemtime, filesize		0.007 ms
getCachedImageDimensions	0.296 ms


the bigger the file is, the more gain we have from using filemtime() and 
filesize() instead of md5_file().

find the patch attached which I used to get these results.

The question is: are we really shure that this works as reliable as with 
hashing the complete file?

greets
rupert




Martin Kutschker schrieb:
> JoH asenau schrieb:
>>> mtime is enough imho. Anytime you change the pic, mtime change too. So
>>> this is the cheapest check and the only needed.
>>> If you don't agree, give me an example where mtime change and file is
>>> identical.
>> Open the file in Photoshop
>> change something
>> save the file
>> revert the change because you noticed it was wrong
>> save the file
>> =>
>> different mtime
>> same content
>>
>> :-)
> 
> Yeah, but this is an edge case. This won't hurt performance in a real
> world situation. For me the mtime and size check is enough. That is if
> *either* mtime *or* the size has changed recreate the image.
> 
> Masi



More information about the TYPO3-performance mailing list