Re: [JPublish-developer] Small performance change
Brought to you by:
aeden
From: Anthony E. <me...@an...> - 2003-03-07 17:08:35
|
I have commited the change. Please let me know if you find any additional bottlenecks. Sincerely, Anthony Eden David E Jones wrote: > Anthony, > > Yes, the performance hit is pretty big. My profiling timings put the running > of that method at around 1ms. This on its own is not huge, but does result in > some cases in OFBiz ecommerce pages the increase of about 10ms of unnecessary > time. > > I was looking for this sort of thing last night in the OFBiz code and noticed > this one here in JPublish. I'll be looking in more detail at JPublish and > other projects over the next few days to find other similar things. A few > milliseconds here and there could result in dropping the total page load time > by a couple of hundred milliseconds, which is what I am going for. > > Later, > -David > > > On Friday 07 March 2003 06:50, Anthony Eden wrote: > >>The idea of having a map of classes was to support the addition of new URI >>types without having to change the code. However if you are showing a >>significant performance hit because of it I will modify the code to match >>your patch. >> >>-Anthony >> >>David E Jones wrote: >> >>>This method is called quite a few times, to the point where it is a >>>noticeable amount. It doesn't look like the dynamic new instance is >>>necessary, and a new is much faster, so attached is an alternative. >>> >>>Later, >>>-David Jones >>> >>> >>>------------------------------------------------------------------------ >>> >>>package org.jpublish.util; >>> >>>import java.util.HashMap; >>> >>>public class InternalURIParser{ >>> >>> private static final InternalURIParser INSTANCE = new >>>InternalURIParser(); //private HashMap uriClasses; >>> >>> protected InternalURIParser(){ >>> //uriClasses = new HashMap(); >>> //uriClasses.put("template", InternalURI.class); >>> //uriClasses.put("repository", RepositoryURI.class); >>> } >>> >>> public static InternalURIParser getInstance(){ >>> return INSTANCE; >>> } >>> >>> public InternalURI parse(String uriString) throws Exception{ >>> int protocolTerminatorIndex = uriString.indexOf(":"); >>> if(protocolTerminatorIndex <= 0){ >>> throw new IllegalArgumentException("URI string is not a valid >>>URI"); } >>> >>> String protocol = uriString.substring(0, >>>protocolTerminatorIndex); //Class uriClass = >>>(Class)uriClasses.get(protocol); >>> //InternalURI uri = (InternalURI)uriClass.newInstance(); >>> InternalURI uri = null; >>> if ("template".equals(protocol)) { >>> uri = new InternalURI(); >>> } else if ("repository".equals(protocol)) { >>> uri = new RepositoryURI(); >>> } else { >>> return null; >>> } >>> uri.setURI(uriString); >>> return uri; >>> } >>> >>>} >> >>------------------------------------------------------- >>This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger >>for complex code. Debugging C/C++ programs can leave you feeling lost and >>disoriented. TotalView can help you find your way. Available on major UNIX >>and Linux platforms. Try it free. www.etnus.com >>_______________________________________________ >>Jpublish-developer mailing list >>Jpu...@li... >>https://lists.sourceforge.net/lists/listinfo/jpublish-developer > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNIX > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Jpublish-developer mailing list > Jpu...@li... > https://lists.sourceforge.net/lists/listinfo/jpublish-developer |