Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 41934 invoked by uid 500); 14 Jun 2002 15:54:41 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 41922 invoked from network); 14 Jun 2002 15:54:41 -0000 From: "Per Kreipke" To: Subject: Speedup *DirectoryGenerator (e.g. ImageDirectoryGenerator et al)... Date: Fri, 14 Jun 2002 11:56:55 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 In-Reply-To: Importance: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N After looking at ImageDirectoryGenerator, which runs about 3x slower than DirectoryGenerator on image files, I think the following changes will speed it up (and similarily, MP3DirectoryGenerator). For fun, compare DirectoryGenerator against ImageDirectoryGenerator on the same directory (with a moderate number of images: Wouldn't it be nice if the second time you requested the image info, it was as fast as the DirectoryGenerator? Suggestions: - having getSize() call getFileType() and then getJpegSize() or getGifSize(), introduces nice modularity but sacrifices speed. Each function in that sequence calls (that's two calls total): new BufferedInputStream(new FileInputStream(file)); Instead, instantiate the BufferedInputStream in getSize() and pass it to the other functions. Or move the work from getFileType() and get*Size() back in to getSize(). - more importantly, caching the information from getSize() plus 'lastModified' in an internal hash table with the file's URL as key would remove the need to do the expensive work each time. If the file hasn't changed, then it's size (or MP3 info) hasn't either. Unfortunately, I don't know Cocoon well enough to understand if Generators are global instances (so that all requests will share the hash table) or whether it exists per pipeline, per sitemap, etc. My point: I'm not sure how to implement the cached info correctly. I would love to do this work and send in the patch myself, and I'll attempt to do so when I have the latest C2 source installed here. Unless someone desparate does it first :-) Per --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org