Are you sure you are getting bad performance out of calling "new" too
many times? I would be interested to see benchmarks showing the
performance.

The JVM is very smart, worrying about using a "new" vs not is usually
is a losing battle. Brian Goetz has some good presentations on this
topic I have attended, and 99% of the time trying to be smart and
write fast code (by not using new(), etc.) gave me code that ran the
same or slower than the more readable version of the code.

On a side note, a URL fetch is an external request, very likely taking
100-500ms. Making a new object is a few cycles of the processor. I
think you are optimizing at the wrong level, if you can cache the
results of your URL fetch you could have 10000x the performance of
avoiding calls to new.



On Jan 10, 4:04 pm, devadvocate <david.jonathan.nel...@gmail.com>
wrote:
> I'm working on an algorithm that runs in a tight loop.  I don't want
> to call new() on anything every time I want to change my url I am
> going to use for a rest call via urlfetch.  however, the java.net
> httpclient, url, urlstreamhandler, and the urlfetch HTTPRequest all
> require this.  In c#/.net there is a factory for creating new
> httpwebrequest objects each time you want to change the url.
>
> All I really need is a setUrl(String url) method I can call on an
> instantiated urlfetch HTTPRequest object.  Why does this not exist?  I
> have found this to be quite a pain point.   I could easily write my
> own implementation with raw tcp sockets if app engine supported that.
>
> Does anyone know of a workaround here?  Any plans to add an instance
> method to HTTPRequest for setUrl(String url)?
>
> Thanks,
> David Nelsonhttp://developeradvocate.appspot.comhttp://twitter.com/devadvocate
-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to