Subject: | Insists on creating output file when loaded even with start=no |
I wanted to use Devel::NYTProf at runtime, enabling profiling only at
certain points and controlling which file is written to.
However, Devel::NYTProf insists on creating an output file when loading
it, even if it's told not to start automatically, with e.g.:
$ENV{NYTPROF} = "start:no";
require Devel::NYTProf;
The workaround I had to use (in Dancer::Plugin::NYTProf) is to get a
temporary filename via File::Temp and pass that to Devel::NYTProf, so it
can create that file, then unlink the file straight afterwards (as it's
not desired), then enable profiling to the the file it should actually
write to at desired points at runtime with DB::enable_profile($filename).
This works, but is obviously quite hackish.
My expectation was that, if I'd told Devel::NYTProf *not* to start
profiling until I manually started it, that it would not attempt to open
a file for output until I told it to. It seems to me that it would make
sense for opening an output file to be deferred until profiling is
actually starting, to avoid this issue biting anyone else.