Bench-marking cfdirectory v. java.io.file

Today I’m working on decreasing execution time on a script that does a couple DB querys and cfdirectory lists. After some preliminary testing my gut perception has proven true; the exorbinate execution time is due to cfdirectory.

So I set out to find a faster way of getting file information from directories and sure enough taking things back to Java is the way to go. See my benchmark code below and the results. I’m sure you’ll agree.

        // UNC path to look in
	curDir = '\myuncpath';

	// ftime will hold the execution time
	// fio is our java.io.File object
	ftime = gettickcount();
		fio = createObject('java','java.io.File');
		mylist = fio.init(trim(curDir)).list();
	ftime = gettickcount() - ftime;

I run the exact same thing in cfdirectory (tumblr strips cfml tags from posts or i”d post that here too). The results in my case show: files: 3409, ftime: 31, dtime: 17608.

That’s 3409 files. Java returns a list of names in 31ms while cfdirectory does the same in 17.5 seconds.



,

One Comment to “Bench-marking cfdirectory v. java.io.file”

  1. [...] Look below for a little function I wrote to convert an array to a query. I had to write this to allow for my use of java.io.File.list() rather than cfdirectory due to speed limitations of the latter. More on that with benchmarks later here. [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This entry was posted on October 27, 2011 and is filed under Coldfusion. Written by: . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.