clientperf 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/clientperf.gemspec +3 -3
 - data/lib/clientperf.rb +1 -1
 - data/lib/clientperf_config.rb +2 -1
 - data/lib/clientperf_controller.rb +1 -0
 - data/lib/clientperf_uri.rb +75 -12
 - data/views/clientperf/index.html.erb +6 -5
 - data/views/clientperf/show.html.erb +18 -5
 - data/views/layouts/clientperf.html.erb +44 -4
 - metadata +2 -2
 
    
        data/clientperf.gemspec
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
     | 
    
         
            -
            # Gem::Specification for Clientperf-0.0. 
     | 
| 
      
 2 
     | 
    
         
            +
            # Gem::Specification for Clientperf-0.0.3
         
     | 
| 
       3 
3 
     | 
    
         
             
            # Originally generated by Echoe
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.name = %q{clientperf}
         
     | 
| 
       7 
     | 
    
         
            -
              s.version = "0.0. 
     | 
| 
      
 7 
     | 
    
         
            +
              s.version = "0.0.3"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              s.specification_version = 2 if s.respond_to? :specification_version=
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.authors = ["Eric Falcao"]
         
     | 
| 
       13 
     | 
    
         
            -
              s.date = %q{2008-06- 
     | 
| 
      
 13 
     | 
    
         
            +
              s.date = %q{2008-06-20}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.default_executable = %q{clientperf}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.description = %q{Instrumentation for the FiveRuns TuneUp product.}
         
     | 
| 
       16 
16 
     | 
    
         
             
              s.email = %q{efalcao@gmail.com}
         
     | 
    
        data/lib/clientperf.rb
    CHANGED
    
    
    
        data/lib/clientperf_config.rb
    CHANGED
    
    
    
        data/lib/clientperf_uri.rb
    CHANGED
    
    | 
         @@ -1,22 +1,85 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ClientperfUri < ActiveRecord::Base
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
              
         
     | 
| 
      
 3 
     | 
    
         
            +
              has_many :clientperf_results, :dependent => :delete_all do
         
     | 
| 
      
 4 
     | 
    
         
            +
                def last_hour
         
     | 
| 
      
 5 
     | 
    
         
            +
                  end_time = (Time.now + 1.minute).change(:sec => 0)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  start_time = end_time - 1.hour
         
     | 
| 
      
 7 
     | 
    
         
            +
                  results = average(:milliseconds, :conditions => ['created_at between ? and ?', start_time, end_time] ,
         
     | 
| 
      
 8 
     | 
    
         
            +
                    :group => 'minute(created_at)')
         
     | 
| 
      
 9 
     | 
    
         
            +
                  
         
     | 
| 
      
 10 
     | 
    
         
            +
                  max = 0  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  padded_results = (start_time.min..start_time.min + 59).map do |i|
         
     | 
| 
      
 12 
     | 
    
         
            +
                    minute = i % 60
         
     | 
| 
      
 13 
     | 
    
         
            +
                    data = data_for(minute, results)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    max = data if data && data > max
         
     | 
| 
      
 15 
     | 
    
         
            +
                    [minute, data]
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  [padded_results, max]
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                def last_day
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end_time = (Time.now + 1.hour).change(:min => 0)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  start_time = end_time - 1.day
         
     | 
| 
      
 23 
     | 
    
         
            +
                  results = average(:milliseconds, :conditions => ['created_at between ? and ?', start_time, end_time], 
         
     | 
| 
      
 24 
     | 
    
         
            +
                    :group => 'hour(created_at)')
         
     | 
| 
      
 25 
     | 
    
         
            +
                  
         
     | 
| 
      
 26 
     | 
    
         
            +
                  max = 0  
         
     | 
| 
      
 27 
     | 
    
         
            +
                  padded_results = (start_time.hour..start_time.hour + 23).map do |i|
         
     | 
| 
      
 28 
     | 
    
         
            +
                    hour = i % 24
         
     | 
| 
      
 29 
     | 
    
         
            +
                    data = data_for(hour, results)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    max = data if data && data > max
         
     | 
| 
      
 31 
     | 
    
         
            +
                    [hour, data]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                  [padded_results, max]  
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
                
         
     | 
| 
      
 36 
     | 
    
         
            +
                def last_month
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end_time = (Time.now + 1.day).change(:hour => 0)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  start_time = end_time - 30.days
         
     | 
| 
      
 39 
     | 
    
         
            +
                  results = average(:milliseconds, :conditions => ['created_at between ? and ?', start_time, end_time], 
         
     | 
| 
      
 40 
     | 
    
         
            +
                    :group => 'day(created_at)')
         
     | 
| 
      
 41 
     | 
    
         
            +
                    
         
     | 
| 
      
 42 
     | 
    
         
            +
                  max = 0  
         
     | 
| 
      
 43 
     | 
    
         
            +
                  padded_results = (start_time.day..start_time.day + 29).map do |i|
         
     | 
| 
      
 44 
     | 
    
         
            +
                    day = i % Time.days_in_month(start_time.month)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    data = data_for(day, results)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    max = data if data && data > max
         
     | 
| 
      
 47 
     | 
    
         
            +
                    [day, data]
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
                  [padded_results, max]
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
                
         
     | 
| 
      
 52 
     | 
    
         
            +
                def data_for(point, results)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  data = results.detect {|p,d| point == p.to_i}
         
     | 
| 
      
 54 
     | 
    
         
            +
                  data ? data[1].to_i : 0
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
              end 
         
     | 
| 
       7 
57 
     | 
    
         | 
| 
       8 
58 
     | 
    
         
             
              def chart_url
         
     | 
| 
       9 
     | 
    
         
            -
                "http://chart.apis.google.com/chart?cht=ls&chs= 
     | 
| 
      
 59 
     | 
    
         
            +
                "http://chart.apis.google.com/chart?cht=ls&chs=300x50&chm=B&chd=s:"
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
              
         
     | 
| 
      
 62 
     | 
    
         
            +
              def hour_chart
         
     | 
| 
      
 63 
     | 
    
         
            +
                "#{chart_url}#{chart_data(clientperf_results.last_hour)}"
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
              
         
     | 
| 
      
 66 
     | 
    
         
            +
              def day_chart
         
     | 
| 
      
 67 
     | 
    
         
            +
                "#{chart_url}#{chart_data(clientperf_results.last_day)}"
         
     | 
| 
       10 
68 
     | 
    
         
             
              end
         
     | 
| 
       11 
69 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
      
 70 
     | 
    
         
            +
              def month_chart
         
     | 
| 
      
 71 
     | 
    
         
            +
                "#{chart_url}#{chart_data(clientperf_results.last_month)}"
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
       13 
73 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
      
 74 
     | 
    
         
            +
              private
         
     | 
| 
      
 75 
     | 
    
         
            +
              
         
     | 
| 
      
 76 
     | 
    
         
            +
              def chart_data(args)
         
     | 
| 
      
 77 
     | 
    
         
            +
                data, max = args
         
     | 
| 
      
 78 
     | 
    
         
            +
                max += 10
         
     | 
| 
       15 
79 
     | 
    
         
             
                encode = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  char = 62 * result.milliseconds / max_value.to_f
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                data.map do |result|
         
     | 
| 
      
 82 
     | 
    
         
            +
                  char = 62 * result[1] / max.to_f
         
     | 
| 
       20 
83 
     | 
    
         
             
                  encode[char.round,1]
         
     | 
| 
       21 
84 
     | 
    
         
             
                end.join
         
     | 
| 
       22 
85 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            <h2>all urls</h2>
         
     | 
| 
       2 
2 
     | 
    
         
             
            <table>
         
     | 
| 
       3 
3 
     | 
    
         
             
            	<tr>
         
     | 
| 
       4 
     | 
    
         
            -
            		<td> 
     | 
| 
      
 4 
     | 
    
         
            +
            		<td>URL</td>
         
     | 
| 
       5 
5 
     | 
    
         
             
            		<td># of times measured</td>
         
     | 
| 
       6 
6 
     | 
    
         
             
            		<td>avg. client time (ms)</td>
         
     | 
| 
       7 
7 
     | 
    
         
             
            		<td>first measured</td>
         
     | 
| 
         @@ -10,10 +10,11 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            	<% @uris.each do |uri| %>
         
     | 
| 
       11 
11 
     | 
    
         
             
            	<tr>
         
     | 
| 
       12 
12 
     | 
    
         
             
            		<td><%= link_to uri.uri, "/clientperf/#{uri.id}" %></td>
         
     | 
| 
       13 
     | 
    
         
            -
            		<td><%= uri.clientperf_results. 
     | 
| 
       14 
     | 
    
         
            -
            		<td><%= uri. 
     | 
| 
      
 13 
     | 
    
         
            +
            		<td><%= uri.clientperf_results.count %></td>
         
     | 
| 
      
 14 
     | 
    
         
            +
            		<td><%= uri.clientperf_results.average(:milliseconds).to_i %></td>
         
     | 
| 
       15 
15 
     | 
    
         
             
            		<td><%= uri.created_at.strftime("%M/%d/%y") %></td>
         
     | 
| 
       16 
16 
     | 
    
         
             
            		<td><%= uri.updated_at.strftime("%M/%d/%y") %></td>
         
     | 
| 
       17 
17 
     | 
    
         
             
            	</tr>
         
     | 
| 
       18 
18 
     | 
    
         
             
            	<% end %>
         
     | 
| 
       19 
     | 
    
         
            -
            </table>
         
     | 
| 
      
 19 
     | 
    
         
            +
            </table>
         
     | 
| 
      
 20 
     | 
    
         
            +
            <p><%= button_to "Reset all data", {:action => 'reset'},  :confirm => "are you sure?" %></p>
         
     | 
| 
         @@ -1,5 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            < 
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            < 
     | 
| 
       5 
     | 
    
         
            -
            < 
     | 
| 
      
 1 
     | 
    
         
            +
            <h2>summary</h2>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <p>recorded <%= @uri.clientperf_results.count %> times with average time of <%= @uri.clientperf_results.average(:milliseconds).to_i %>ms. last recorded <%= @uri.updated_at.strftime("%Y-%m-%d") %>.</p>
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            <h2>trends</h2>
         
     | 
| 
      
 5 
     | 
    
         
            +
            <div class="chart">
         
     | 
| 
      
 6 
     | 
    
         
            +
            	<h4>last hour</h4>
         
     | 
| 
      
 7 
     | 
    
         
            +
            	<img src="<%= @uri.hour_chart %>" />
         
     | 
| 
      
 8 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <div class="chart">
         
     | 
| 
      
 10 
     | 
    
         
            +
            	<h4>last day</h4>
         
     | 
| 
      
 11 
     | 
    
         
            +
            	<img src="<%= @uri.day_chart %>" />
         
     | 
| 
      
 12 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 13 
     | 
    
         
            +
            <div class="chart">
         
     | 
| 
      
 14 
     | 
    
         
            +
            	<h4>last month</h4>
         
     | 
| 
      
 15 
     | 
    
         
            +
            	<img src="<%= @uri.month_chart %>" />
         
     | 
| 
      
 16 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            <p><%= button_to "Reset this URI", {:action => 'reset', :id => @uri.id},  :confirm => "are you sure?" %></p>
         
     | 
| 
         @@ -1,12 +1,52 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <html>
         
     | 
| 
       2 
2 
     | 
    
         
             
            	<head>
         
     | 
| 
       3 
     | 
    
         
            -
            		<title 
     | 
| 
      
 3 
     | 
    
         
            +
            		<title>clientperf <%= ": #{@page_title}" if @page_title %></title>
         
     | 
| 
       4 
4 
     | 
    
         
             
            		<style type="text/css">
         
     | 
| 
      
 5 
     | 
    
         
            +
            			body {margin:0; font-family: helvetica, arial, sans-serif; font-size: 14px;}
         
     | 
| 
      
 6 
     | 
    
         
            +
            			
         
     | 
| 
      
 7 
     | 
    
         
            +
            			#header {
         
     | 
| 
      
 8 
     | 
    
         
            +
            				background-color: #dedede;
         
     | 
| 
      
 9 
     | 
    
         
            +
            				border-bottom: 2px solid #bbb;
         
     | 
| 
      
 10 
     | 
    
         
            +
            				padding: 5px 20px;
         
     | 
| 
      
 11 
     | 
    
         
            +
            			}
         
     | 
| 
      
 12 
     | 
    
         
            +
            			
         
     | 
| 
      
 13 
     | 
    
         
            +
            			#header h1, #header h3 {
         
     | 
| 
      
 14 
     | 
    
         
            +
            				color: #222;
         
     | 
| 
      
 15 
     | 
    
         
            +
            				margin: 0;
         
     | 
| 
      
 16 
     | 
    
         
            +
            				padding: 0;
         
     | 
| 
      
 17 
     | 
    
         
            +
            			}
         
     | 
| 
      
 18 
     | 
    
         
            +
            			
         
     | 
| 
      
 19 
     | 
    
         
            +
            			#header h1 a {
         
     | 
| 
      
 20 
     | 
    
         
            +
            				color: inherit;
         
     | 
| 
      
 21 
     | 
    
         
            +
            				text-decoration: none;
         
     | 
| 
      
 22 
     | 
    
         
            +
            			}
         
     | 
| 
      
 23 
     | 
    
         
            +
            			
         
     | 
| 
      
 24 
     | 
    
         
            +
            			#header h3 {
         
     | 
| 
      
 25 
     | 
    
         
            +
            				margin-top: 0px;
         
     | 
| 
      
 26 
     | 
    
         
            +
            				font-size: 14px;
         
     | 
| 
      
 27 
     | 
    
         
            +
            			}
         
     | 
| 
      
 28 
     | 
    
         
            +
            			
         
     | 
| 
      
 29 
     | 
    
         
            +
            			#header h3 span {
         
     | 
| 
      
 30 
     | 
    
         
            +
            			}
         
     | 
| 
      
 31 
     | 
    
         
            +
            			
         
     | 
| 
      
 32 
     | 
    
         
            +
            			#content {
         
     | 
| 
      
 33 
     | 
    
         
            +
            				padding: 0 20px;
         
     | 
| 
      
 34 
     | 
    
         
            +
            			}
         
     | 
| 
      
 35 
     | 
    
         
            +
            			
         
     | 
| 
      
 36 
     | 
    
         
            +
            			#content h2 {
         
     | 
| 
      
 37 
     | 
    
         
            +
            				margin-top: 20px;
         
     | 
| 
      
 38 
     | 
    
         
            +
            				border-bottom: 1px solid #d3d3d3;
         
     | 
| 
      
 39 
     | 
    
         
            +
            			}
         
     | 
| 
       5 
40 
     | 
    
         
             
            		</style>
         
     | 
| 
       6 
41 
     | 
    
         
             
            	</head>
         
     | 
| 
       7 
42 
     | 
    
         
             
            	<body>
         
     | 
| 
       8 
     | 
    
         
            -
            		< 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
            		<div id="header">
         
     | 
| 
      
 44 
     | 
    
         
            +
            			<h1><%= link_to "clientperf", :controller => 'clientperf', :action => 'index' %></h1>
         
     | 
| 
      
 45 
     | 
    
         
            +
            			<%= "<h3><span>»</span>#{@uri.uri}</h3>" if @uri %>
         
     | 
| 
      
 46 
     | 
    
         
            +
            			<div style="clear:both"></div>
         
     | 
| 
      
 47 
     | 
    
         
            +
            		</div>
         
     | 
| 
      
 48 
     | 
    
         
            +
            		<div id="content">
         
     | 
| 
      
 49 
     | 
    
         
            +
            			<%= yield %>
         
     | 
| 
      
 50 
     | 
    
         
            +
            		</div>
         
     | 
| 
       11 
51 
     | 
    
         
             
            	</body>
         
     | 
| 
       12 
52 
     | 
    
         
             
            </html>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: clientperf
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Eric Falcao
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2008-06- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-06-20 00:00:00 -05:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |