Re: [morph-user] Morph's use of toString()
Brought to you by:
orangeherbert,
sgarlatm
|
From: Matt S. <sga...@us...> - 2005-06-06 14:27:33
|
Hi Hernan,
When is MorphUtil.getObjectDescription called? I think my intention was
for it to only be called when writing TRACE output to the log file. As
you point out, calling this method is incredibly expensive so in a
production system it should definitely not be called.
Matt
Hernan Silberman wrote:
>I've been doing lots of profiling today and I noticed that my JavaBeans involved
>in Morph transformations are getting their toString() methods called.
>
>This happens in MorphUtil.getObjectDescription( Object object ). The else of
>the MorphUtils.getObjectDescription() method looks like this:
>
>else {
> return
> getDelimiter(object) + object +
> getDelimiter(object) + " (class " +
> object.getClass().getName() + ")";
>}
>
>This results in a call to String method:
>
>public static String valueOf(Object obj) {
> return (obj == null) ? "null" : obj.toString();
>}
>
>...which is where the toString() call on my objects is coming from.
>
>This is a fairly serious performance issue for me, because my toString()
>methods are usually not very fast and intended for human eyes (the
>java.lang.Object javadoc says "The result should be a concise but informative
>representation that is easy for a person to read."). I have use cases that
>routinely include Morphing hundreds of objects... times many possible threads,
>every bit counts.
>
>Any way to avoid doing the toString() in MorphUtil.getObjectDescription()?
>
>I'm using Morph 0.8.3.
>
>many thanks!
>Hernan
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
>a projector? How fast can you ride your desk chair down the office luge track?
>If you want to score the big prize, get to know the little guy.
>Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
>_______________________________________________
>morph-user mailing list
>mor...@li...
>https://lists.sourceforge.net/lists/listinfo/morph-user
>
>
>
|