perf_check 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0044f60e2a24034b680d872ba644802609544bd
4
- data.tar.gz: a6af1d7e8a2fa0407874e4c0a37081da8de5941c
3
+ metadata.gz: e429268ea248d238130f873494e04bdf8b74a3fd
4
+ data.tar.gz: 49cd55f1113f6f31492a84c273d58761d1ce824f
5
5
  SHA512:
6
- metadata.gz: 7cefb6316cea89e4f891a6430407001a22bf44757e08e857247bdda84eaa75f2fe9c1b545c2556a1d1e3f2ec8b24941d34d3b41518572217a6bcb375075e0f46
7
- data.tar.gz: 8212ec527aa899f2a57efbbba827eee7a01751112377055f98d31599fcb50aa0476dd092e9aa71cb76021b88c8720af9086089849b80f67b312f4cb11f53d053
6
+ metadata.gz: 263a12324d08e02724e6ef92703a02a0ea13e5cf07c846550189c628aaba177c5662492089745d6f172e5cab2ef5be7e46039ee6ed8100f6ebc8cf1f6bcd9872
7
+ data.tar.gz: 56b851ddfd60cc6192c04cedafc2c715983cf01c930135da2881d2bacc5b62edc2eaac70092c68e2f2b14c404f9003f4596c8ba1ce893ba62a771669225138f6
@@ -21,8 +21,6 @@ class PerfCheck
21
21
  config = ActiveSupport::Configurable::Configuration
22
22
  config.send(:define_method, :perform_caching){ fragment_caching }
23
23
  end
24
-
25
- PerfCheck::Server.seed_random!
26
24
  end
27
25
  end
28
26
  end
@@ -35,29 +35,6 @@ class PerfCheck
35
35
  end
36
36
  end
37
37
 
38
- def self.seed_random!
39
- # Seed random, for --verify purposes
40
- srand(1)
41
-
42
- # SecureRandom cannot be seeded, so we have to monkey patch it instead
43
-
44
- def SecureRandom.hex(n=16)
45
- '4' * n
46
- end
47
- def SecureRandom.random_bytes(n=16)
48
- '4' * n
49
- end
50
- def SecureRandom.random_number(n=0)
51
- n > 4 ? 4 : n
52
- end
53
- def SecureRandom.urlsafe_base64(n=16, padding=false)
54
- '4' * (4*n / 3)
55
- end
56
- def SecureRandom.uuid
57
- "00000000-0000-0000-0000-000000000004"
58
- end
59
- end
60
-
61
38
  def self.sign_cookie_data(key, data, opts={})
62
39
  opts[:serializer] ||= Marshal
63
40
  secret = Rails.application.config.secret_token
@@ -103,7 +80,7 @@ class PerfCheck
103
80
  mp_link
104
81
  end
105
82
 
106
- def profile
83
+ def profile
107
84
  http = Net::HTTP.new(host, port).tap{ |http| http.read_timeout = 1000 }
108
85
  response = nil
109
86
  prepare_to_profile
@@ -3,7 +3,7 @@
3
3
  class PerfCheck
4
4
  class TestCase
5
5
  attr_accessor :resource, :controller, :action, :format
6
- attr_accessor :cookie, :this_response, :reference_response
6
+ attr_accessor :latencies, :cookie
7
7
  attr_accessor :this_latencies, :reference_latencies
8
8
 
9
9
  def initialize(route)
@@ -11,6 +11,7 @@ class PerfCheck
11
11
 
12
12
  self.this_latencies = []
13
13
  self.reference_latencies = []
14
+ self.latencies = this_latencies
14
15
 
15
16
  self.controller = params[:controller].split('/')[-1]
16
17
  self.action = params[:action]
@@ -18,18 +19,12 @@ class PerfCheck
18
19
  self.resource = route
19
20
  end
20
21
 
21
- def switch_to_reference_context
22
- @context = :reference
23
- end
24
-
25
22
  def run(server, options)
26
23
  print("\t"+'request #'.underline)
27
24
  print(" "+'latency'.underline)
28
25
  print(" "+'server rss'.underline)
29
26
  puts(" "+'profiler data'.underline)
30
27
 
31
- latencies = (@context == :reference) ? reference_latencies : this_latencies
32
-
33
28
  headers = {'Cookie' => "#{cookie}"}
34
29
  unless self.format
35
30
  headers['Accept'] = 'text/html,application/xhtml+xml,application/xml'
@@ -51,19 +46,10 @@ class PerfCheck
51
46
  end
52
47
 
53
48
  next if i.zero?
54
-
55
- if i == 1
56
- if @context == :reference
57
- self.reference_response = profile.response_body
58
- else
59
- self.this_response = profile.response_body
60
- end
61
- end
62
-
63
49
  printf("\t%2i:\t %.1fms %4dMB\t %s\n",
64
50
  i, profile.latency, server.mem, profile.profile_url)
65
51
 
66
- latencies << profile.latency
52
+ self.latencies << profile.latency
67
53
  end
68
54
  puts
69
55
  end
data/lib/perf_check.rb CHANGED
@@ -57,7 +57,7 @@ class PerfCheck
57
57
  if i == 1
58
58
  Git.stash_if_needed
59
59
  Git.checkout_reference(options.reference)
60
- test_cases.each{ |x| x.switch_to_reference_context }
60
+ test_cases.each{ |x| x.latencies = x.reference_latencies }
61
61
  end
62
62
 
63
63
  test_cases.each do |test|
@@ -110,16 +110,6 @@ class PerfCheck
110
110
  puts("master: ".rjust(15) + "#{master_latency}")
111
111
  puts("your branch: ".rjust(15)+ "#{this_latency}")
112
112
  puts(("change: ".rjust(15) + "#{formatted_change}").bold.send(color))
113
-
114
- Tempfile.new('this_response').tap do |this_response|
115
- Tempfile.new('reference_response').tap do |reference_response|
116
- this_response.write(test.this_response)
117
- reference_response.write(test.reference_response)
118
- this_response.close
119
- reference_response.close
120
- system('diff', '-U0', this_response.path, reference_response.path)
121
- end
122
- end
123
113
  end
124
114
  end
125
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perf_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubytune