phantomherd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWRiOTNjM2MyM2ZkNDE3OTY0ZTU1Mzc1MjA3MTgzOThmYThlNWI0Ng==
5
+ data.tar.gz: !binary |-
6
+ NTY5NmFlMzI1MjJjMGY4Njk4OTY1Y2M0NjIxOGNjNzgzN2Y4ZmJhMw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MmNlODdiNTQ2ZjE5MjM5OWM2YjIwMmRlNzgxZTI1NmJmZjNjODNkMWNhZGM0
10
+ MmYwMWYxN2U1YzZkZDc3ZTI5MzY2Y2VkMmUzYjk2NmZmMTY5YWZkZmI5MTIx
11
+ YjZkM2VjYjVlNTdhYzNlNTdkOTM3M2U5NGVhM2ZiNzlhM2U2NmI=
12
+ data.tar.gz: !binary |-
13
+ OTMxOTM1NTAxNzNiMWRmZDg2OThiMWVlNzRjYWI5MTc4NDc5NjhmNTJhMGQ2
14
+ NWMxYWEzOGQ3ZmM2ODk0YjQyZmM2ZWZmYWI0ODM4MGUxODcxZTcxMjRmZWRi
15
+ ZWM0ZWZhMGQ5ZGRlNTM5MjFhYTA1YzJkMGY4MzViOTNhZGVkMWM=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phantomherd.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nickolas Means
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,33 @@
1
+ # Phantomherd
2
+
3
+ Phantomherd provides a simple way to launch multiple PhantomJS instances in parallel to run a simple load test on your site.
4
+
5
+ ## Installation
6
+
7
+ Install via RubyGems:
8
+
9
+ `$ gem install phantomherd`
10
+
11
+ You'll also need CasperJS, which you can install via Homebrew:
12
+
13
+ `$brew install casperjs --devel`
14
+
15
+ ## Usage
16
+
17
+ To run a basic load test, just supply the name of a CasperJS script to run:
18
+
19
+ `phantomherd test.coffee`
20
+
21
+ This will run the script in two parallel PhantomJS instances and report the results.
22
+
23
+ You can specify a number of samples with the `-s` flag, and the level of concurrency with the `-c` flag.
24
+
25
+ `phantomherd -c 25 -s 100 test.coffee`
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'phantomherd'
4
+ require 'trollop'
5
+
6
+ opts = Trollop::options do
7
+ banner <<-EOB
8
+ phantomherd: simple load testing using EventMachine and PhantomJS/CasperJS
9
+
10
+ Usage:
11
+ phantomherd [options] <CasperJS script filename>
12
+ where [options] are:
13
+ EOB
14
+ opt :sample_count, "Number of times to run CasperJS script", :default => 2
15
+ opt :concurrency, "Number of PhantomJS instances to run concurrently", :default => 2
16
+ end
17
+
18
+ Trollop::die "CasperJS executable not found.\n(Install via Homebrew: `brew install casperjs --devel`)" if `which casperjs` == ""
19
+ Trollop::die "Must specify a CasperJS script to run" if ARGV[0].nil?
20
+ Trollop::die "Cannot find file specified: #{ARGV[0]}" unless File.exist?(ARGV[0])
21
+
22
+ opts[:casper_script] = ARGV[0]
23
+
24
+ Phantomherd::Runner.new(opts).run
@@ -0,0 +1,5 @@
1
+ require "phantomherd/version"
2
+ require "phantomherd/runner"
3
+
4
+ module Phantomherd
5
+ end
@@ -0,0 +1,47 @@
1
+ require "em-synchrony"
2
+ require "em-synchrony/fiber_iterator"
3
+
4
+ module Phantomherd
5
+ class Runner
6
+
7
+ attr_reader :sample_count, :concurrency, :casper_script
8
+ attr_accessor :results
9
+
10
+ def initialize(options)
11
+ @sample_count = options[:sample_count]
12
+ @concurrency = options[:concurrency]
13
+ @casper_script = options[:casper_script]
14
+ @results = []
15
+ end
16
+
17
+ def run
18
+ requests = (1..sample_count.to_i).to_a
19
+ EM.synchrony do
20
+ EM::Synchrony::FiberIterator.new(requests, concurrency).each do |request|
21
+ stime = Time.now
22
+ out, status = EM::Synchrony.system("casperjs --ignore-ssl-errors=yes #{casper_script}")
23
+ print "."
24
+ @results << Time.now - stime
25
+ end
26
+ print "\n"
27
+ EventMachine.stop
28
+ end
29
+ print_results
30
+ end
31
+
32
+ private
33
+
34
+ def print_results
35
+ avg = @results.inject{ |sum, el| sum + el}.to_f / @results.size
36
+ puts "=" * 80
37
+ puts "phantomherd: #{casper_script} (#{sample_count} samples, #{concurrency} concurrent)"
38
+ puts "=" * 80
39
+ puts "Average: #{avg.round(3)} sec"
40
+ puts "Min: #{@results.min.round(3)} sec"
41
+ puts "Max: #{@results.max.round(3)} sec"
42
+ puts "=" * 80
43
+ puts "\nRaw results: \n#{@results.join(",")}"
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Phantomherd
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'phantomherd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "phantomherd"
8
+ spec.version = Phantomherd::VERSION
9
+ spec.authors = ["Nickolas Means"]
10
+ spec.email = ["nick@heliumsyndicate.com"]
11
+ spec.description = %q{Simple load testing with EventMachine and PhantomJS/CasperJS}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/nmeans/phantomherd"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "trollop"
24
+ spec.add_dependency "em-synchrony"
25
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phantomherd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nickolas Means
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: trollop
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
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: em-synchrony
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Simple load testing with EventMachine and PhantomJS/CasperJS
70
+ email:
71
+ - nick@heliumsyndicate.com
72
+ executables:
73
+ - phantomherd
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/phantomherd
83
+ - lib/phantomherd.rb
84
+ - lib/phantomherd/runner.rb
85
+ - lib/phantomherd/version.rb
86
+ - phantomherd.gemspec
87
+ homepage: https://github.com/nmeans/phantomherd
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Simple load testing with EventMachine and PhantomJS/CasperJS
111
+ test_files: []