wbench 0.3.6 → 0.3.7

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: fe21cd9138babb08ef23e967f76d921650ed1ebd
4
- data.tar.gz: 9ee59b415dc1fd6e312404be238521f2c70d23d1
3
+ metadata.gz: 6dfb44fa9da6a36574ee13ee7b541a0beee68cbf
4
+ data.tar.gz: def12740e6a51ddf81d71d8479d1acb150d2fe17
5
5
  SHA512:
6
- metadata.gz: b61abc703677f00323a93b684a22a31b32d4e0a327d858fb14e06cb52afa8d32777039a0a0198b38af494556baaaf2834a420047df2a0c7837e3ba2367ee09e7
7
- data.tar.gz: 1700e343c31202744a33c45d68b8b2f15f3f64c3de4d0f7f4b8b56c98d881eeea855ab6790b1761f1ef490000cc95dbba41caa05503a312f3053e6d464d439ee
6
+ metadata.gz: 0ebecb25fe5ae425c7effb70ea8b7fc2c71a5fde0c0df1865664a81201ef997e1b9bbd0386745bcf3dc6654ee1195df267f15fef5e7d7e94bde9265cc9efac8a
7
+ data.tar.gz: b90b6da372c793a2a28db28f12341d6b5625b0161f2c661133afa3729e9482e2d5b6a83e26b181b90bbfdf88c020623143c76f56869e9f6c572b715e2ac255f8
data/README.md CHANGED
@@ -20,7 +20,7 @@ You will need to install [Google Chrome](http://www.google.com/chrome) as well a
20
20
  You can install chromedriver (on OSX) with homebrew:
21
21
 
22
22
  ```bash
23
- brew install chromedriver
23
+ $ brew install chromedriver
24
24
  ```
25
25
 
26
26
  Alternatively you can install firefox and use it with wbench. See [Running other browsers](#running-other-browsers) for more info.
@@ -32,7 +32,7 @@ Alternatively you can install firefox and use it with wbench. See [Running other
32
32
  Simply enter the URL of a website you want to benchmark. The site will be loaded in the Chrome browser 10 times.
33
33
 
34
34
  ```bash
35
- wbench https://www.desktoppr.co/
35
+ $ wbench https://www.desktoppr.co/
36
36
  ```
37
37
 
38
38
  ![Example Usage Output](https://github.com/desktoppr/wbench/raw/master/example.png)
@@ -42,26 +42,33 @@ wbench https://www.desktoppr.co/
42
42
  Chrome is the default browser that is used. You can also use firefox by specifying it on the command line.
43
43
 
44
44
  ```bash
45
- wbench -b firefox https://www.desktoppr.co/
45
+ $ wbench -b firefox https://www.desktoppr.co/
46
46
  ```
47
47
 
48
48
  ### Setting the user agent
49
49
  You can also pass the `-u/--user-agent` option to change the browsers user agent (This can be useful for mobile testing).
50
50
 
51
51
  ```bash
52
- wbench -u "Mozilla/5.0 (iPhone; U; ..." https://www.desktoppr.co/
52
+ $ wbench -u "Mozilla/5.0 (iPhone; U; ..." https://www.desktoppr.co/
53
53
  ```
54
54
 
55
+ ### Server performance measuring
56
+
57
+ Server response times will be reported if the application is a ruby/rack application that returns the `X-Runtime` http header. Without that header the server performance will not be able to be measured.
58
+
55
59
  ### Ruby API
56
60
 
57
61
  You can programatically run the benchmarks. Simply specify the URL and
58
62
  optionally the amount of runs.
59
63
 
60
- ```bash
64
+ Here is an example of running a benchmark in chrome looping around 3 times.
65
+
66
+ ```ruby
61
67
 
62
68
  require 'wbench'
63
69
 
64
- results = WBench::Benchmark.run('https://www.desktoppr.co/', :loops => 3, :browser => :chrome) # => WBench::Results
70
+ benchmark = WBench::Benchmark.new('https://www.desktoppr.co/', :browser => :chrome)
71
+ results = benchmark.run(3) # => WBench::Results
65
72
 
66
73
  results.app_server # =>
67
74
  [25, 24, 24]
@@ -85,12 +92,37 @@ results.latency # =>
85
92
  "ssl.google-analytics.com"=>[497, 14, 14], "www.desktoppr.co"=>[191, 210, 203]}
86
93
  ```
87
94
 
95
+ ### Benchmarking authenticated pages
96
+
97
+ Benchmarking authenticated pages is possible using the ruby API. The API
98
+ provides direct access to the selenium session. The session allows us to visit
99
+ a login page before our test page, for example:
100
+
101
+ ```ruby
102
+ require 'wbench'
103
+
104
+ benchmark = WBench::Benchmark.new('https://www.desktoppr.co/dashboard', :browser => :chrome)
105
+ benchmark.before_each do
106
+ visit 'https://www.desktoppr.co/login'
107
+ fill_in 'Login', :with => 'mario'
108
+ fill_in 'Password', :with => 'super secret'
109
+ click_button 'Log In'
110
+ end
111
+
112
+ results = benchmark.run(3) # => WBench::Results
113
+ ```
114
+
115
+ Please note that by visiting pages before each run, your browser may cache some
116
+ assets. This means that when the benchmark is run against the authenticated
117
+ page, some assets may be loaded from the cache, and the result may appear
118
+ quicker than an uncahed visit.
119
+
88
120
  ### Gisting results
89
121
 
90
122
  You can install the [Github gist gem](https://github.com/defunkt/gist) and pipe in the results of wbench
91
123
 
92
- ```
93
- gem install gist
124
+ ```bash
125
+ $ gem install gist
94
126
 
95
- wbench http://www.google.com.au/ | gist -d "Google homepage"
127
+ $ wbench http://www.google.com.au/ | gist -d "Google homepage"
96
128
  ```
@@ -9,9 +9,14 @@ module WBench
9
9
  @browser = Browser.new(url, options)
10
10
  end
11
11
 
12
+ def before_each(&blk)
13
+ @before_each = blk
14
+ end
15
+
12
16
  def run(loops)
13
17
  Results.new(@url, loops).tap do |results|
14
18
  loops.times do
19
+ @browser.run(&@before_each)
15
20
  @browser.visit { results.add(app_server_results, browser_results, latency_results) }
16
21
  end
17
22
  end
@@ -3,7 +3,6 @@ module WBench
3
3
  attr_accessor :url
4
4
 
5
5
  def initialize(url, options = {})
6
-
7
6
  Capybara.register_driver(CAPYBARA_DRIVER) do |app|
8
7
  http_client = Selenium::WebDriver::Remote::Http::Default.new
9
8
  http_client.timeout = CAPYBARA_TIMEOUT
@@ -22,17 +21,6 @@ module WBench
22
21
 
23
22
  def visit
24
23
  session.visit(@url)
25
- session.driver.browser.manage.add_cookie({:name => "__cfduid", :value => "d451147018e57384e0b9140acd81e7e651344316083", :path => "/", :secure => false})
26
- session.driver.browser.manage.add_cookie({:name => "__utma", :value => "173654326.679005727.1344316084.1364896914.1364907827.314", :path => "/", :secure => false})
27
- session.driver.browser.manage.add_cookie({:name => "__utmb", :value => "173654326.6.9.1364908479334", :path => "/", :secure => false})
28
- session.driver.browser.manage.add_cookie({:name => "__utmc", :value => "173654326", :path => "/", :secure => false})
29
- session.driver.browser.manage.add_cookie({:name => "__utmz", :value => "173654326.1364523542.301.35.utmcsr=t.co|utmccn=(referral)|utmcmd=referral|utmcct=/zIqI8VD5U9", :path => "/", :secure => false})
30
- session.driver.browser.manage.add_cookie({:name => "_desktoppr_session", :value => "3219d6873f518346124e45aed28b3145", :path => "/", :secure => false})
31
- session.driver.browser.manage.add_cookie({:name => "filter_preferences", :value => "", :path => "/", :secure => false})
32
- session.driver.browser.manage.add_cookie({:name => "gs_u", :value => "1918212640:35447:133481:1352193418568", :path => "/", :secure => false})
33
- session.driver.browser.manage.add_cookie({:name => "remember_user_token", :value => "BAhbB1sGaQdJIiIkMmEkMTAkR1ZLaDBxUk5oY0Q2YmxUWEpjTVJTdQY6BkVU--49ef55778ab2fc2f84b314289b7ea26d10222a40", :path => "/", :secure => false})
34
- session.visit(@url)
35
-
36
24
  wait_for_page
37
25
  session.execute_script(wbench_javascript)
38
26
  yield if block_given?
@@ -43,6 +31,10 @@ module WBench
43
31
  session.evaluate_script(script)
44
32
  end
45
33
 
34
+ def run(&blk)
35
+ session.instance_eval(&blk) if block_given?
36
+ end
37
+
46
38
  private
47
39
 
48
40
  def add_selenium_args(options, arg)
@@ -1,3 +1,3 @@
1
1
  module WBench
2
- VERSION = '0.3.6'
2
+ VERSION = '0.3.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Visic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-14 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.0.0
130
+ rubygems_version: 2.0.3
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Benchmark website loading times