watir-webdriver-performance 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/watir-webdriver-performance.rb +38 -35
- data/watir-webdriver-performance.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -4,41 +4,17 @@ module Watir
|
|
4
4
|
# Adds helper for window.performance to Watir::Browser.
|
5
5
|
# @see http://dev.w3.org/2006/webapi/WebTiming/
|
6
6
|
|
7
|
-
|
7
|
+
class PerformanceHelper
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
word.gsub!(/::/, '/')
|
12
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
13
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
14
|
-
word.tr!("-", "_")
|
15
|
-
word.downcase!
|
16
|
-
word
|
17
|
-
end
|
18
|
-
|
19
|
-
def earliest_timestamp(hash)
|
20
|
-
return hash[:timing][:navigation_start] if hash[:timing][:navigation_start] > 0
|
21
|
-
return hash[:timing][:redirect_start] if hash[:timing][:redirect_start] > 0
|
22
|
-
return hash[:timing][:redirect_end] if hash[:timing][:redirect_end] > 0
|
23
|
-
return hash[:timing][:fetch_start] if hash[:timing][:fetch_start] > 0
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
24
11
|
end
|
25
12
|
|
26
|
-
def
|
27
|
-
return hash[:timing][:load_event_end] if hash[:timing][:load_event_end] > 0
|
28
|
-
return hash[:timing][:load_event_start] if hash[:timing][:load_event_start] > 0
|
29
|
-
return hash[:timing][:dom_complete] if hash[:timing][:dom_complete] > 0
|
30
|
-
return hash[:timing][:dom_content_loaded_event_end] if hash[:timing][:dom_content_loaded_event_end] > 0
|
31
|
-
return hash[:timing][:dom_content_loaded_event_start] if hash[:timing][:dom_content_loaded_event_start] > 0
|
32
|
-
return hash[:timing][:dom_interactive] if hash[:timing][:dom_interactive] > 0
|
33
|
-
return hash[:timing][:response_end] if hash[:timing][:response_end] > 0
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def munge(data)
|
13
|
+
def munge
|
38
14
|
hash = {}
|
39
|
-
data.each_key do |key|
|
15
|
+
@data.each_key do |key|
|
40
16
|
hash[key.to_sym] = {}
|
41
|
-
data[key].each do |k,v|
|
17
|
+
@data[key].each do |k,v|
|
42
18
|
hash[key.to_sym][underscored(k).to_sym] = v
|
43
19
|
end
|
44
20
|
end
|
@@ -64,18 +40,45 @@ module Watir
|
|
64
40
|
hash[:summary][:time_to_last_byte] = hash[:timing][:response_end] -
|
65
41
|
hash[:timing][:domain_lookup_start] if hash[:timing][:domain_lookup_start] > 0
|
66
42
|
hash[:summary][:response_time] = latest_timestamp(hash) - earliest_timestamp(hash)
|
67
|
-
hash
|
43
|
+
OpenStruct.new(hash)
|
68
44
|
end
|
69
45
|
|
70
|
-
|
71
|
-
|
72
|
-
|
46
|
+
private
|
47
|
+
|
48
|
+
def underscored(camel_cased_word)
|
49
|
+
word = camel_cased_word.to_s.dup
|
50
|
+
word.gsub!(/::/, '/')
|
51
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
52
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
53
|
+
word.tr!("-", "_")
|
54
|
+
word.downcase!
|
55
|
+
word
|
56
|
+
end
|
57
|
+
|
58
|
+
def earliest_timestamp(hash)
|
59
|
+
return hash[:timing][:navigation_start] if hash[:timing][:navigation_start] > 0
|
60
|
+
return hash[:timing][:redirect_start] if hash[:timing][:redirect_start] > 0
|
61
|
+
return hash[:timing][:redirect_end] if hash[:timing][:redirect_end] > 0
|
62
|
+
return hash[:timing][:fetch_start] if hash[:timing][:fetch_start] > 0
|
63
|
+
end
|
64
|
+
|
65
|
+
def latest_timestamp(hash)
|
66
|
+
return hash[:timing][:load_event_end] if hash[:timing][:load_event_end] > 0
|
67
|
+
return hash[:timing][:load_event_start] if hash[:timing][:load_event_start] > 0
|
68
|
+
return hash[:timing][:dom_complete] if hash[:timing][:dom_complete] > 0
|
69
|
+
return hash[:timing][:dom_content_loaded_event_end] if hash[:timing][:dom_content_loaded_event_end] > 0
|
70
|
+
return hash[:timing][:dom_content_loaded_event_start] if hash[:timing][:dom_content_loaded_event_start] > 0
|
71
|
+
return hash[:timing][:dom_interactive] if hash[:timing][:dom_interactive] > 0
|
72
|
+
return hash[:timing][:response_end] if hash[:timing][:response_end] > 0
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
76
76
|
|
77
77
|
class Browser
|
78
|
-
|
78
|
+
def performance
|
79
|
+
data = driver.execute_script("return window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance;")
|
80
|
+
PerformanceHelper.new(data).munge
|
81
|
+
end
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{watir-webdriver-performance}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tim Koopmans"]
|
12
|
-
s.date = %q{2011-04-
|
12
|
+
s.date = %q{2011-04-20}
|
13
13
|
s.description = %q{This gem collects and summarises metrics speficied in the W3C Navigation web performance specifications at http://w3c-test.org/webperf/specs/NavigationTiming/ when using watir-webdriver and a compatible browser}
|
14
14
|
s.email = %q{tim.koops@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-webdriver-performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Koopmans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-20 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|