Subject: Re: bug#22114: 24.5; [PATCH] Allow profiler.el to display reports after stopping

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Dec 2015 19:28:53 +0200

> Date: Tue, 8 Dec 2015 17:32:08 +0100
> From: Vasilij Schneidermann <[email-masked]>
> Cc: [email-masked]
> 
> > Thanks.  But I don't see why we would need to keep a copy of the
> > profile around (and it looks weird to do that anyway, when we have a
> > function that reports it).  When profiler-cpu-log is called, it
> > returns the profile before it resets it, so the data is available and
> > should simply be used.
> > 
> > I don't really understand why profiler.el insists on having the
> > profiler running for providing the profile.  The much simpler patch
> > below makes it possible for me to invoke profiler-report whether a
> > profile is running or not.  Does it work for you?  If not, can you
> > tell what I missed?
> 
> This works only once.  If the profiler has been stopped and you retrieve
> the log, it resets and subsequent access will yield an error.

But why would you need a subsequent access to the same data?  The
profiler report is in the buffer, and you can review it whenever you
want.  The buffer has the time of the report creation as part of its
name, so the next report will not destroy the buffer.  You can also
save the report to a file (there's a separate command to do that).  By
contrast,producing a report again from the same data will simply
produce an identical report.

I guess I don't see a use case where the user would need to produce
the same report twice.  I never needed that myself, FWIW.

> While your variant may be simpler, it is less user-friendly as
> viewing the report a second time will yield an incomprehensible
> error.

If the error message needs improvement, we could do that as well.

> Avoiding this either requires fixing the function retrieving the log
> (which is at the C level and out of my reach) or using a workaround
> like the two extra variables in my patch.

The code implemented in C resets the data deliberately (there are
comments there that explain why), so it cannot be fixed.