Skip to content

Commit

Permalink
Write datestamped profiles
Browse files Browse the repository at this point in the history
Differential Revision: D52745862

fbshipit-source-id: a7888ad12b457809f225500d09de53b9e84f309c
  • Loading branch information
dafyddcrosby authored and facebook-github-bot committed Jan 17, 2024
1 parent 363bf82 commit 613e802
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spec/fbspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'ruby-prof' if ENV['FB_RSPEC_PROFILING']
require 'chefspec'
require 'chefspec/lib/chefspec/matchers/render_file_matcher.rb'

Expand All @@ -33,13 +32,18 @@ def self.fbspec_init(cookbook_path, platforms)
end
config.cookbook_path = cookbook_path
if ENV['FB_RSPEC_PROFILING']
require 'ruby-prof'
config.before(:example) do
RubyProf.start
end
config.after(:example) do
result = RubyProf.stop
printer = RubyProf::GraphPrinter.new(result)
printer.print($stdout)
profile_name = "rspec_profile-#{DateTime.now.iso8601(4)}.out"
File.open(profile_name, 'w+') do |file|
printer.print(file)
end
puts "Rspec profiling dumped to #{profile_name}"
end
end
end
Expand Down

0 comments on commit 613e802

Please sign in to comment.