[jboss-dev] Further profling: Where should I focus?
Jason T. Greene
jason.greene at redhat.com
Wed Jan 6 11:18:07 EST 2010
Andrew Dinn wrote:
> On 01/05/2010 07:42 PM, Bill Burke wrote:
>> public List<Closeable> recursiveMount(VirtualFile file) throws
>> IOException
>> {
>> ArrayList<Closeable> mounts = new ArrayList<Closeable>();
>>
>> if (!file.isDirectory()&&
>> file.getName().matches("^.*\\.([EeWwJj][Aa][Rr]|[Zz][Ii][Pp])$"))
>> mounts.add(VFS.mountZip(file, file, provider));
>>
>> /****** Doubled speedup when this was commented out!!!!!!!!!!!!
>> if (file.isDirectory())
>> for (VirtualFile child : file.getChildren())
>> mounts.addAll(recursiveMount(child));
>> */
>>
>>
>> return mounts;
>> }
>
> Irrespective of the answer to any general issues over caching it is
> clear in this case that the 2 calls to file.isDirectory() can quite
> legitimately be replaced with a single call and a local variable to
> stash/test the result (it's a shame the compiler cannot figure this out
> but so it goes). Since this code actually turned up in the profiling as
> a major source of overhead then the obvious thing to do in response is
> patch it and see what turns up next then keep going until easy to fix
> things like this stop turning up. Saves us wasting time in protracted
> arguments as well ;-)
In addition you don't want to do regex matching like that. However, code
like this is not actually going to be in the AS, it was just a quick and
dirty routine for a test case. So that bit was blown out of proportion.
--
Jason T. Greene
JBoss, a division of Red Hat
More information about the jboss-development
mailing list