You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Berin Loritsch <bl...@apache.org> on 2002/03/07 15:55:53 UTC

Intrumenting Question and Thought

How often are profilables registered with the profiler?  The
question arrizes out of a possibility to make the API a little
nicer.

If this action happens very often, the API needs to stay the same
because arrays are more efficient.

However, if the action only happens once in a great while (like
during initialization), we should take advantage of the Java
collections API to make things a bit smoother.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Intrumenting Question and Thought

Posted by Leif Mortenson <le...@silveregg.co.jp>.

Marcus Crafter wrote:

>On Thu, Mar 07, 2002 at 09:55:53AM -0500, Berin Loritsch wrote:
>
>>How often are profilables registered with the profiler?  The
>>question arrizes out of a possibility to make the API a little
>>nicer.
>>
>>If this action happens very often, the API needs to stay the same
>>because arrays are more efficient.
>>
>>However, if the action only happens once in a great while (like
>>during initialization), we should take advantage of the Java
>>collections API to make things a bit smoother.
>>
>
>	I don't think it's the registration of profilables that would be done
>	all that often - it's probably more the traversal of
>	profilables/profile points to select which will be sampled, etc.
>
What part of the API are you referring to?  Profilables are only 
registered when they are
created.  This means that ThreadSafe components are only registered 
once.  Poolable, once
for each new instance.  But the SingleThreaded components are registered 
once for each
instance, which translates into once per lookup.

Do you mean the getProfilePoints() and getChildProfilables() methods in 
the Profilable interface?
I felt that arrays were a good choice here because the implementor has 
more choices in how they
create the array.
Also the code this way looks like this:
    public ProfilePoint[] getProfilePoints()
    {
        return new ProfilePoint[]
        {
            m_randomQuickProfilePoint,
            m_randomSlowProfilePoint,
            m_randomRandomProfilePoint,
            m_counterQuickProfilePoint,
            m_counterSlowProfilePoint,
            m_counterRandomProfilePoint,
            m_doActionProfilePoint
        };
    }

as opposed to:
    public Collection getProfilePoints()
    {
        ArrayList list = new ArrayList(7);
        list.add( m_randomQuickProfilePoint );
        list.add( m_randomSlowProfilePoint );
        list.add( m_randomRandomProfilePoint );
        list.add( m_counterQuickProfilePoint );
        list.add( m_counterSlowProfilePoint );
        list.add( m_counterRandomProfilePoint );
        list.add( m_doActionProfilePoint );
        return list;
    }

I like the first choice :-)

I make use of arrays in many other APIs to avoid synchronization issues. 
 The arrays are created
as needed and then stored outside of any synchronization.  This makes it 
easy for the 99.9% of
the calls in which the contents of the array have not changed.

Cheers,
Leif

Re: Intrumenting Question and Thought

Posted by Marcus Crafter <cr...@fztig938.bank.dresdner.net>.
On Thu, Mar 07, 2002 at 09:55:53AM -0500, Berin Loritsch wrote:
> How often are profilables registered with the profiler?  The
> question arrizes out of a possibility to make the API a little
> nicer.
> 
> If this action happens very often, the API needs to stay the same
> because arrays are more efficient.
> 
> However, if the action only happens once in a great while (like
> during initialization), we should take advantage of the Java
> collections API to make things a bit smoother.

	I don't think it's the registration of profilables that would be done
	all that often - it's probably more the traversal of
	profilables/profile points to select which will be sampled, etc.

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>