wbench 0.2.3 → 0.3.0
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -1
- data/README.md +22 -2
- data/Rakefile +9 -0
- data/bin/wbench +4 -0
- data/lib/wbench.rb +1 -0
- data/lib/wbench/benchmark.rb +3 -3
- data/lib/wbench/browser.rb +15 -6
- data/lib/wbench/timings/app_server.rb +1 -1
- data/lib/wbench/version.rb +1 -1
- data/wbench.gemspec +1 -0
- metadata +25 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f7c3ab6f6b1bb434b62f44eb6a9582418755f78
|
4
|
+
data.tar.gz: 51108410717cd0394a47c0a9789363077d2ac6aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61e348f82ba38fc6d287d2108b517420e0b10b4d84edbd1ab625d4d19b0755197b1043a33da5749bb5a9286ec2e94bcbd54e9a6ee1d56d23695e964e717bafc3
|
7
|
+
data.tar.gz: 9a4145da2076f46482d3723f696183d2f0068650e5bedb30281b88e5149192152a58db8dc36719d9288ee58e870f22561caa097dfe4f05d1ed017184c93fdd6f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,12 @@ You can install the latest stable gem by running:
|
|
10
10
|
$ gem install wbench
|
11
11
|
```
|
12
12
|
|
13
|
+
If you're running an older version (1.8) of ruby, you'll need the JSON gem.
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ gem install json
|
17
|
+
```
|
18
|
+
|
13
19
|
You will need to install [Google Chrome](http://www.google.com/chrome) as well as the chromedriver utility.
|
14
20
|
You can install chromedriver (on OSX) with homebrew:
|
15
21
|
|
@@ -39,6 +45,13 @@ Chrome is the default browser that is used. You can also use firefox by specifyi
|
|
39
45
|
wbench -b firefox https://www.desktoppr.co/
|
40
46
|
```
|
41
47
|
|
48
|
+
### Setting the user agent
|
49
|
+
You can also pass the `-u/--user-agent` option to change the browsers user agent (This can be useful for mobile testing).
|
50
|
+
|
51
|
+
```bash
|
52
|
+
wbench -u "Mozilla/5.0 (iPhone; U; ..." https://www.desktoppr.co/
|
53
|
+
```
|
54
|
+
|
42
55
|
### Ruby API
|
43
56
|
|
44
57
|
You can programatically run the benchmarks. Simply specify the URL and
|
@@ -72,5 +85,12 @@ results.latency # =>
|
|
72
85
|
"ssl.google-analytics.com"=>[497, 14, 14], "www.desktoppr.co"=>[191, 210, 203]}
|
73
86
|
```
|
74
87
|
|
75
|
-
|
76
|
-
|
88
|
+
### Gisting results
|
89
|
+
|
90
|
+
You can install the [Github gist gem](https://github.com/defunkt/gist) and pipe in the results of wbench
|
91
|
+
|
92
|
+
```
|
93
|
+
gem install gist
|
94
|
+
|
95
|
+
wbench http://www.google.com.au/ | gist -d "Google homepage"
|
96
|
+
```
|
data/Rakefile
CHANGED
data/bin/wbench
CHANGED
data/lib/wbench.rb
CHANGED
data/lib/wbench/benchmark.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module WBench
|
2
2
|
class Benchmark
|
3
3
|
def self.run(url, options = {})
|
4
|
-
new(url, options
|
4
|
+
new(url, options).run(options[:loops] || DEFAULT_LOOPS)
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize(url,
|
7
|
+
def initialize(url, options = {})
|
8
8
|
@url = url
|
9
|
-
@browser = Browser.new(url,
|
9
|
+
@browser = Browser.new(url, options)
|
10
10
|
end
|
11
11
|
|
12
12
|
def run(loops)
|
data/lib/wbench/browser.rb
CHANGED
@@ -2,24 +2,27 @@ module WBench
|
|
2
2
|
class Browser
|
3
3
|
attr_accessor :url
|
4
4
|
|
5
|
-
def initialize(url,
|
5
|
+
def initialize(url, options = {})
|
6
|
+
browser = options[:browser] || DEFAULT_BROWSER
|
7
|
+
|
6
8
|
Capybara.register_driver(CAPYBARA_DRIVER) do |app|
|
7
9
|
http_client = Selenium::WebDriver::Remote::Http::Default.new
|
8
10
|
http_client.timeout = CAPYBARA_TIMEOUT
|
9
11
|
|
10
|
-
|
12
|
+
opts = { :browser => browser.to_sym, :http_client => http_client }
|
13
|
+
opts[:args] = ["--user-agent='#{options[:ua]}'"] if options[:ua]
|
14
|
+
|
15
|
+
SeleniumDriver.new(app, opts)
|
11
16
|
end
|
12
17
|
|
13
|
-
@url = url
|
18
|
+
@url = Addressable::URI.parse(url).normalize.to_s
|
14
19
|
end
|
15
20
|
|
16
21
|
def visit
|
17
22
|
session.visit(@url)
|
18
|
-
|
23
|
+
wait_for_page
|
19
24
|
session.execute_script(wbench_javascript)
|
20
|
-
|
21
25
|
yield if block_given?
|
22
|
-
|
23
26
|
close
|
24
27
|
end
|
25
28
|
|
@@ -48,5 +51,11 @@ module WBench
|
|
48
51
|
|
49
52
|
@script = jquery.read + stringify.read + wbench.read
|
50
53
|
end
|
54
|
+
|
55
|
+
def wait_for_page
|
56
|
+
Selenium::WebDriver::Wait.new(:timeout => CAPYBARA_TIMEOUT).until do
|
57
|
+
session.evaluate_script('document.readyState') == 'complete'
|
58
|
+
end
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
@@ -2,7 +2,7 @@ module WBench
|
|
2
2
|
module Timings
|
3
3
|
class AppServer
|
4
4
|
def initialize(browser)
|
5
|
-
uri = URI.parse(browser.url)
|
5
|
+
uri = Addressable::URI.parse(browser.url)
|
6
6
|
@http = Net::HTTP.new(uri.host, uri.port)
|
7
7
|
@http.use_ssl = uri.scheme == 'https'
|
8
8
|
@request = Net::HTTP::Get.new(uri.request_uri)
|
data/lib/wbench/version.rb
CHANGED
data/wbench.gemspec
CHANGED
metadata
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wbench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mario Visic
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-02
|
11
|
+
date: 2013-03-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capybara
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: colorize
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: addressable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: '0'
|
46
55
|
description: WBench is a tool that uses the HTML5 performance timing API to benchmark
|
@@ -86,27 +95,26 @@ files:
|
|
86
95
|
- wbench.gemspec
|
87
96
|
homepage: ''
|
88
97
|
licenses: []
|
98
|
+
metadata: {}
|
89
99
|
post_install_message:
|
90
100
|
rdoc_options: []
|
91
101
|
require_paths:
|
92
102
|
- lib
|
93
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
104
|
requirements:
|
96
|
-
- -
|
105
|
+
- - '>='
|
97
106
|
- !ruby/object:Gem::Version
|
98
107
|
version: '0'
|
99
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
109
|
requirements:
|
102
|
-
- -
|
110
|
+
- - '>='
|
103
111
|
- !ruby/object:Gem::Version
|
104
112
|
version: '0'
|
105
113
|
requirements: []
|
106
114
|
rubyforge_project:
|
107
|
-
rubygems_version:
|
115
|
+
rubygems_version: 2.0.0
|
108
116
|
signing_key:
|
109
|
-
specification_version:
|
117
|
+
specification_version: 4
|
110
118
|
summary: Benchmark website loading times
|
111
119
|
test_files:
|
112
120
|
- spec/spec_helper.rb
|