Class: OverallStatsReport

Inherits:
GenericReport show all
Defined in:
lib/pqa.rb

Instance Method Summary collapse

Methods inherited from GenericReport

#applicable, #colorize, #initialize, #pctg_of, #round

Constructor Details

This class inherits a constructor from GenericReport

Instance Method Details

#find_longestObject



935
936
937
938
939
940
941
942
# File 'lib/pqa.rb', line 935

def find_longest  
  q = Query.new("No queries found")
  @log.queries.max {|a,b| 
    return b if a.duration.nil?
    return a if b.duration.nil?
    a.duration <=> b.duration 
  }
end

#find_shortestObject



926
927
928
929
930
931
932
933
# File 'lib/pqa.rb', line 926

def find_shortest  
  q = Query.new("No queries found")
  @log.queries.min {|a,b| 
    return b if a.duration.nil?
    return a if b.duration.nil?
    a.duration <=> b.duration 
  }
end

#htmlObject



897
898
899
900
901
902
903
904
905
906
907
908
909
# File 'lib/pqa.rb', line 897

def html
  rpt = "<h3>#{title}</h3>\n"
  rpt << "#{@log.queries.size} queries\n"
  rpt << "<br>#{@log.unique_queries} unique queries\n"
  if @log.includes_duration
    rpt << "<br>Total query duration was #{round(total_duration, 2)} seconds\n"
    longest = find_longest
    rpt << "<br>Longest query (#{colorize(longest.text)}) ran in #{"%2.3f" % longest.duration} seconds\n"
    shortest = find_shortest
    rpt << "<br>Shortest query (#{colorize(shortest.text)}) ran in #{"%2.3f" % shortest.duration} seconds\n"
  end
  rpt << "<br>Log file parsed in #{"%2.1f" % @log.time_to_parse} seconds\n"
end

#textObject



915
916
917
918
919
920
# File 'lib/pqa.rb', line 915

def text
  rpt = "######## #{title}\n"
  rpt << "#{@log.queries.size} queries (#{@log.unique_queries} unique)"
  rpt << ", longest ran in #{find_longest.duration} seconds)," if @log.includes_duration
  rpt << " parsed in #{@log.time_to_parse} seconds\n"
end

#titleObject



911
912
913
# File 'lib/pqa.rb', line 911

def title  
  "Overall statistics"
end

#total_durationObject



922
923
924
# File 'lib/pqa.rb', line 922

def total_duration
  @log.queries.inject(0) {|sum, q| sum += (q.duration != nil) ? q.duration : 0  }
end