Merge pull request #4908 from jekyll/add-timing-cucumber

Merge pull request 4908
This commit is contained in:
jekyllbot 2016-06-13 14:23:41 -07:00 committed by GitHub
commit eba9a2716b
1 changed files with 34 additions and 9 deletions

View File

@ -30,6 +30,7 @@ module Jekyll
@options = options
@exceptions = []
@indent = 0
@timings = {}
end
#
@ -42,6 +43,7 @@ module Jekyll
def after_features(features)
@io.puts
print_worst_offenders
print_summary(features)
end
@ -54,23 +56,35 @@ module Jekyll
#
def feature_element_timing_key(feature_element)
"\"#{feature_element.name.to_s.sub("Scenario: ", "")}\" (#{feature_element.location})"
end
#
def before_feature_element(feature_element)
@indent = 2
@scenario_indent = 2
@timings[feature_element_timing_key(feature_element)] = Time.now
end
#
def after_feature_element(feature_element)
@timings[feature_element_timing_key(feature_element)] = Time.now - @timings[feature_element_timing_key(feature_element)]
@io.print " (#{@timings[feature_element_timing_key(feature_element)]}s)"
end
#
def tag_name(tag_name); end
def comment_line(comment_line); end
def after_feature_element(feature_element); end
def after_tags(tags); end
#
def before_feature_element(_feature_element)
@indent = 2
@scenario_indent = 2
end
#
def before_background(_background)
@scenario_indent = 2
@in_background = true
@ -178,6 +192,17 @@ module Jekyll
#
def print_worst_offenders
@io.puts
@io.puts "Worst offenders:"
@timings.sort_by { |_f, t| -t }.take(10).each do |(f, t)|
@io.puts " #{t}s for #{f}"
end
@io.puts
end
#
def print_summary(features)
@io.puts
print_stats(features, @options)