httpProfiler 0.0.1

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.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in httpProfiler.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ httpProfiler (0.0.1)
5
+ bundler (~> 1.3)
6
+ curb
7
+ floatstats
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ curb (0.8.4)
13
+ floatstats (0.2.1)
14
+ rake (10.1.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.3)
21
+ httpProfiler!
22
+ rake
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 PerceptiSys Ltd (Stephen Gaito)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # HttpProfiler
2
+
3
+ HttpProfiler uses [curb](https://github.com/taf2/curb) and
4
+ [floatstats](https://github.com/fizquierdo/floatstats) to compute
5
+ connection time statistics for configurable collections of webserver
6
+ urls.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'httpProfiler'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install httpProfiler
21
+
22
+ ## Usage
23
+
24
+ ### Command line
25
+
26
+ For help type:
27
+
28
+ > httpProfiler --help
29
+
30
+ Invoking the example YAML configuration file:
31
+
32
+ > httpProfiler $HTTP_TIMER_GEM/examples/httpProfiler.yaml
33
+
34
+ ### Library
35
+
36
+ > require 'httpProfiler'
37
+
38
+ > results = HttpProfiler.run(configFileName, configHash);
39
+ > results.each_pair do | requestGroupName, requestGroupResults |
40
+ > puts "#{requestGroupName}, #{requestGroupResults.join(', ')}";
41
+ > end
42
+
43
+ The results is a Hash whose keys are the requestGroupNames taken from
44
+ the configHash, and whose results are the curb derived connection time
45
+ min, average, median, maximum and stardard deviations for all of the
46
+ urls in each requestGroup.
47
+
48
+ See the $HTTP_TIMER_GEM/examples/httpProfiler.yaml file for documentation
49
+ of the configuration options.
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
58
+
59
+ ## License
60
+
61
+ Released under the [MIT](http://opensource.org/licenses/MIT) license
62
+ (see LICENSE.txt).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/ToDo.md ADDED
@@ -0,0 +1,14 @@
1
+ # ToDo
2
+
3
+ ## High priority
4
+
5
+ 1. implement the abilitiy to extract cookies from previous visits to
6
+ urls in order to implement typcial login behaviour.
7
+
8
+ ## Medium priority
9
+
10
+ 1. Allow the delay to be randomized between minDelay and maxDelay
11
+
12
+ ## Low priority
13
+
14
+ Nothing at the moment.
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This ruby script runs the httpProfiler and then prints the results
4
+ # to stdout.
5
+
6
+ require 'rubygems' unless defined?(Gem);
7
+ require 'bundler/setup';
8
+
9
+ require 'optparse';
10
+ require 'yaml';
11
+ require 'httpProfiler';
12
+
13
+ defaultOptions = Hash.new();
14
+ defaultOptions['verbose'] = false;
15
+ defaultOptions['randomize'] = -1;
16
+ defaultOptions['replications'] = 10;
17
+ defaultOptions['delay'] = 1.0;
18
+
19
+ cmdOptions = Hash.new();
20
+
21
+ OptionParser.new do | opts |
22
+
23
+ opts.banner = "Usage: httpProfiler [options] CONFIG_FILE";
24
+
25
+ opts.on("-r", "--repl REPLICATIONS", "The default number of replications to perform of each url-hash-key x url combination") do | opt |
26
+ cmdOptions['replications'] = opt.to_i;
27
+ end
28
+
29
+ opts.on("-R", "--rand RANDOM_SEED", "The (integer) random seed, zero for no randomization, negative to use the current time as the random seed") do | opt |
30
+ cmdOptions['randomize'] = opt.to_i;
31
+ end
32
+
33
+ opts.on("-d", "--delay DELAY_SECONDS", "The (float) number of seconds to delay between each request, if zero or negative then no delay will be used") do | opt |
34
+ cmdOptions['delay'] = opt.to_f;
35
+ end
36
+
37
+ opts.on("-v", "--[no-]verbose", "Toggle verbose output to stdout (default: false)") do | opt |
38
+ cmdOptions['verbose'] = opt;
39
+ end
40
+
41
+ end.parse!(ARGV)
42
+
43
+ ARGV.each do | configFile |
44
+ if File.exists?(configFile) then
45
+ config = YAML::load_file(configFile);
46
+ config = defaultOptions.merge(config);
47
+ config.merge!(cmdOptions);
48
+ timings = HttpProfiler.run(configFile, config);
49
+ puts "\n\nrequestGroupName, minConnTime, meanConnTime, medianConnTime, maxConnTime, stdDevConnTime";
50
+ timings.each_pair do | key, results |
51
+ puts "#{key}, #{results.join(', ')}";
52
+ end
53
+ puts "\n\n";
54
+ else
55
+ puts "Warning: the httpProfiler configuration file [#{configFile}] does not exist...";
56
+ end
57
+ end
@@ -0,0 +1,65 @@
1
+ # This is a simple (ruby) YAML file which determines what the
2
+ # httpProfiler should time, and how it should go about conducting the
3
+ # timings.
4
+
5
+ # Many websites will require logins and will store session and login
6
+ # information in one or more cookies. SO we ensure any cookies defined
7
+ # in this section are obtained before attempting to visit any of the
8
+ # mail urls below.
9
+ #
10
+ # The cookies themselves are stored in the "cookies" hash with
11
+ # arbitrary hash keys (used below to reference the cookies).
12
+ #
13
+ # Each cookie is really a simple string of key=value pairs extracted
14
+ # from the result of visiting the corresponding url.
15
+ #
16
+ cookies: {}
17
+
18
+ # The collection of urls to be visited are listed in the urls hash.
19
+ #
20
+ requestGroups:
21
+ fandianPF:
22
+ urls:
23
+ - http://github.com/fandianpf/fandianpf
24
+ - http://github.com/fandianpf/fandianpf/wiki/Home
25
+ - http://github.com/fandianpf/fandianpf/issues
26
+ httpProfiler:
27
+ urls:
28
+ - http://github.com/stephengaito/httpProfiler
29
+ - http://github.com/stephengaito/httpProfiler/issues
30
+
31
+ # The randomize int determines whether or not to visit the urls in a
32
+ # deterministic sequential (lexigraphical) order (by hash key and url)
33
+ # or to visit them in a random order.
34
+ #
35
+ # If the randomize int is zero then no randomization will take place.
36
+ # If the randomize int is negative, then the randomization seed will
37
+ # be taken from the current time. If the randomize int is positive,
38
+ # than that number will be used as the randomization seed.
39
+ #
40
+ randomize: -1
41
+
42
+ # The replication int determines the global default number of
43
+ # replications for each hash key, url provided.
44
+ #
45
+ replications: 10
46
+
47
+ # The delay float determines how many seconds to wait between requests.
48
+ #
49
+ # A negative or zero value means there will be no delay between requests.
50
+ #
51
+ delay: 0.5
52
+
53
+ # Headers is a hash of key value pairs to provide as default headers
54
+ # for each request.
55
+ #
56
+ # This hash will be merged with corresponding headers hashes contained
57
+ # in the urls structure.
58
+ #
59
+ headers:
60
+ User-Agent: httpProfiler
61
+
62
+ # Verbose is a boolean which specifies if extra verbose output should
63
+ # be sent to the stdout.
64
+ #
65
+ verbose: true
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'httpProfiler'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "httpProfiler"
8
+ spec.version = HttpProfiler::VERSION
9
+ spec.authors = ["Stephen Gaito"]
10
+ spec.email = ["stephen@perceptisys.co.uk"]
11
+ spec.description = %q{Run simple (sequencial) tests on a collection
12
+ of urls to determine average, stardard deviation and median connection
13
+ times}
14
+ spec.summary = %q{Run simple (sequential) tests on a collection of
15
+ urls}
16
+ spec.homepage = "https://github.com/stephengaito/httpProfiler"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+
27
+ spec.add_dependency "bundler", "~> 1.3"
28
+ spec.add_dependency "curb"
29
+ spec.add_dependency "floatstats"
30
+ end
@@ -0,0 +1,89 @@
1
+ #require "httpProfiler/version"
2
+ require 'curb';
3
+ require 'floatstats';
4
+
5
+ module HttpProfiler
6
+ VERSION = "0.0.1";
7
+
8
+ class Runner
9
+
10
+ def initialize(configFileName, config)
11
+ @configFileName = configFileName;
12
+ @options = config;
13
+ @cookies = Hash.new();
14
+ if @options.has_key?('cookies') then
15
+ @cookies = @options['cookies'];
16
+ @options.delete('cookies');
17
+ end
18
+ @requestGroups = Hash.new();
19
+ if @options.has_key?('requestGroups') then
20
+ @requestGroups = @options['requestGroups'];
21
+ @options.delete('requestGroups');
22
+ end
23
+ end
24
+
25
+ def runRequestGroup(requestGroupName, requestGroup)
26
+ requestList = Array.new();
27
+ @options['replications'].times do
28
+ requestGroup['urls'].each do | url |
29
+ requestList.push(url);
30
+ end
31
+ end
32
+
33
+ randGen = nil;
34
+ if requestGroup['randomize'] == 0 then
35
+ elsif requestGroup['randomize'] < 0 then
36
+ randGen = Random.new();
37
+ else
38
+ randGen = Random.new(requestGroup['randomize']);
39
+ end
40
+ requestList.shuffle!(random: randGen) unless randGen.nil?;
41
+
42
+ connectTimes = Array.new();
43
+
44
+ puts requestGroupName if @options['verbose'];
45
+ requestList.each do | url |
46
+ puts "\t#{url}" if @options['verbose'];
47
+ c = Curl::Easy.new(url);
48
+ c.follow_location = true;
49
+ c.perform;
50
+ connectTimes.push(c.connect_time);
51
+ if 0 < @options['delay'] then
52
+ puts "\t\tsleeping(#{@options['delay']})" if @options['verbose'];
53
+ sleep(@options['delay']);
54
+ end
55
+ end
56
+
57
+ [ connectTimes.min,
58
+ connectTimes.average,
59
+ connectTimes.median,
60
+ connectTimes.max,
61
+ connectTimes.standard_deviation ]
62
+ end
63
+
64
+ def run
65
+ if @options['verbose'] then
66
+ require 'pp';
67
+ puts "\n\nConfiguration taken from: [#{@configFileName}]";
68
+ puts "options:";
69
+ pp @options;
70
+ puts "requestGroups:";
71
+ pp @requestGroups;
72
+ puts "\n\n";
73
+ end
74
+ results = Hash.new();
75
+ @requestGroups.each_pair do | requestGroupName, requestGroup |
76
+ results[requestGroupName] = runRequestGroup(requestGroupName,
77
+ requestGroup.merge!(@options));
78
+ end
79
+ results;
80
+ end
81
+
82
+ end
83
+
84
+ def self.run(configFile, config)
85
+ runner = HttpProfiler::Runner.new(configFile, config);
86
+ runner.run;
87
+ end
88
+
89
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: httpProfiler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stephen Gaito
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: curb
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: floatstats
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! "Run simple (sequencial) tests on a collection \nof urls to determine
95
+ average, stardard deviation and median connection \ntimes"
96
+ email:
97
+ - stephen@perceptisys.co.uk
98
+ executables:
99
+ - httpProfiler
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - .gitignore
104
+ - Gemfile
105
+ - Gemfile.lock
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - ToDo.md
110
+ - bin/httpProfiler
111
+ - examples/httpProfiler.yaml
112
+ - httpProfiler.gemspec
113
+ - lib/httpProfiler.rb
114
+ homepage: https://github.com/stephengaito/httpProfiler
115
+ licenses:
116
+ - MIT
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.23
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Run simple (sequential) tests on a collection of urls
139
+ test_files: []
140
+ has_rdoc: