You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Ruby its common to use the helpful Pathname class to represent a path to a file. However, if you use this with stackprof you get an exception with no helpful stacktrace (because the IO flush happens in the compiled library).
2.4.0 :063 > StackProf.run(mode: :cpu, out: Rails.root.join("tmp/stackprof-cpu.dump")) do
2.4.0 :064 > 10.times {2**10}
2.4.0 :065?> end
NoMethodError: undefined method `flush' for nil:NilClass
from (irb):63:in `run'
[rest of stacktrace removed because it's not helpful, and only shows the Ruby call stack down to the console]
However, if you call .to_son the end of the pathname object then it works:
StackProf.run(mode: :cpu, out: Rails.root.join("tmp/stackprof-cpu.dump").to_s) do
2.4.0 :055 > 10.times {2**10}
2.4.0 :056?> end
=> #<File:/[...]/tmp/stackprof-cpu.dump>
Presumably this is due to the fact that (upon reading the code) it seems that the out parameter can take eithert an IO object or a file path. In which case, this should be documented, and / or checked internally and converted to a string if necessary.
This caused much head-scratching and gnashing of teeth!
The text was updated successfully, but these errors were encountered:
The code for `stackprof_results` currently only does checks to see if
the VALUE for `_stackprof.out` is a T_STRING, otherwise it assumes it is
an IO object.
This updates the code to first check if Pathname has been required and
defined, and if it is and the _stackprof.out is a Pathname, then open a
file in the same manner as if it was a string, but calls `.to_s` to
convert it to a ruby string first.
Fixestmm1#79
The code for `stackprof_results` currently only does checks to see if
the VALUE for `_stackprof.out` is a `T_STRING`, otherwise it assumes it
is an IO object.
This updates the code to first check if `Pathname` has been required and
defined. If it is and the `_stackprof.out` is a `Pathname`, then open a
file in the same manner as if it was a string, but calls `.to_s` to
convert it to a ruby string first.
Fixestmm1#79
In Ruby its common to use the helpful Pathname class to represent a path to a file. However, if you use this with stackprof you get an exception with no helpful stacktrace (because the IO flush happens in the compiled library).
However, if you call
.to_s
on the end of the pathname object then it works:Presumably this is due to the fact that (upon reading the code) it seems that the
out
parameter can take eithert an IO object or a file path. In which case, this should be documented, and / or checked internally and converted to a string if necessary.This caused much head-scratching and gnashing of teeth!
The text was updated successfully, but these errors were encountered: