octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: First plans on a profiler


From: John W. Eaton
Subject: Re: First plans on a profiler
Date: Wed, 25 May 2011 11:40:30 -0400

On 25-May-2011, Jordi Gutiérrez Hermoso wrote:

| On 25 May 2011 06:06, Daniel Kraft <address@hidden> wrote:
| > On 24 May 2011 13:01, John W. Eaton <address@hidden> wrote:
| >
| >> I don't know how best to record the timings, but here is an
| >> possible way:
| >>
| >>   * Define a class profile_data_accumulator. This class should
| >>     probably be a singleton object since we likely only want one
| >>     profiler at a time to be active and using a singleton helps to
| >>     avoid initialization problems. There are other singleton
| >>     objects in Octave and they all use a similar style, so it would
| >>     be best to follow the style of the others.
| >
| > I was thinking about something similar -- and thanks for the hint
| > with the already existing singletons, I'll then try to mimic their
| > style of course.
| >
| > Just one thought I also had: Do we possibly want to allow for
| > multiple profiler objects the user also has access to, like via
| > Octave's OOP interface? So that he/she could have profilers in
| > parallel and accumulate data on each of them based on the needs? I
| > can't think of a situation when that would be really useful, though.
| > So probably the singleton is just fine. (And it should not be too
| > hard to change that later if we really would want to have multiple
| > profilers possible.)
| 
| Perhaps I'm wrong, but singleton in me evokes an unpleasant knee-jerk
| reaction that goes something to the tune of this:
| 
|      http://sites.google.com/site/steveyegge2/singleton-considered-stupid

That just told me I would probably never want to work for or with that
guy...

| If Octave gets improved parallelisation and threading support,
| couldn't you potentially want to have one profiler per thread? In that
| case, wouldn't it make sense to make a normal object instead of a
| singleton?

I'm not sure.  Singletons can be modified to handle multiple
instances.  I still thing they are useful regardless of the rantings
you provided the link to.

| Or if we really do want a singleton, wouldn't a bunch of
| free-standing functions in some namespace do just as well, instead of
| trying to jam them all as static functions of a class? Singletons are
| often just namespaced global objects, and C++ has other ways to
| accomplish namespacing than classes.

The problem that singletons solve for me is initialization of static
objects.  If there is no static data then the singleton object is
probably the wrong thing.  What is the lifetime of the profiler
object?  Where should it live?  Where is it initialized?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]