newrelic-shoes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9218f8077a0e4b95d532eb0d7e8e1c13047a27d8
4
+ data.tar.gz: e479c8a1afe9bb99ea6be6ae8c8b6eedb1760fcb
5
+ SHA512:
6
+ metadata.gz: 261af292aca2de60d024330497fcd9d6ab5070ab1e699a0cdc003be3d6cdb9af56253dd3111d01a69c76498d52bbdf37295c37d89d75433bd27a82bf545351c4
7
+ data.tar.gz: 12b29a1a1edf20ed989d08facddd43743666c3ee0697130885ccd48de56489de57699b1227c38211ea4e79be27706bc7105add50290ae9efbcad97987c6afb6d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in newrelic-shoes.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jason R. Clark
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # NewRelic::Shoes
2
+
3
+ `newrelic-shoes` brings New Relic's method tracing to Shoes for local
4
+ development performance testing.
5
+
6
+ ## Installation
7
+
8
+ ```ruby gem 'newrelic-shoes' ```
9
+
10
+ You may find it necessary to `bundle exec bin/shoes` to get things loading
11
+ right.
12
+
13
+ ## Usage
14
+
15
+ Once the gem is installed in your Shoes application, press Ctrl+Alt+N to start
16
+ New Relic tracing. At exit the Shoes custom metrics are emitted to STDOUT.
17
+
18
+ Future plans include an embedded developer mode and transactions for layout and
19
+ painting, but for now the targetted metrics are useful when tuningk specific
20
+ methods that aren't easily isolated to a benchmark (i.e. painting).
21
+
22
+ ## Development
23
+
24
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
25
+ `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To
28
+ release a new version, update the version number in `version.rb`, and then run
29
+ `bundle exec rake release` to create a git tag for the version, push git
30
+ commits and tags, and push the `.gem` file to
31
+ [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/jasonrclark/newrelic-shoes/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "newrelic/shoes"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ require "newrelic/shoes/version"
2
+ require "newrelic/shoes/instrumentation"
3
+ require "newrelic/shoes/reporter"
4
+
5
+ puts "New Relic for Shoes is available. Press Ctrl+Alt+N to start tracing.\n\n"
6
+
7
+ Shoes::InternalApp.add_global_keypress(:'control_alt_n') do
8
+
9
+ puts "Tracing with New Relic for Shoes! Your metrics will output at exit.\n\n"
10
+ NewRelic::Shoes::Instrumentation.install
11
+
12
+ at_exit do
13
+ NewRelic::Shoes::Reporter.new.report
14
+ end
15
+ end
@@ -0,0 +1,34 @@
1
+ require "new_relic/agent"
2
+ require "new_relic/agent/method_tracer"
3
+
4
+ module NewRelic
5
+ module Shoes
6
+ module Instrumentation
7
+ def self.install
8
+ NewRelic::Agent.manual_start(monitor_mode: false, developer: true)
9
+
10
+ trace(::Shoes::Swt::Common::Painter, :paint_control)
11
+ trace(::Shoes::Swt::Common::Painter, :paint_object)
12
+ trace(::Shoes::Swt::Common::Painter, :fill_setup)
13
+ trace(::Shoes::Swt::Common::Painter, :draw_setup)
14
+ trace(::Shoes::Swt::Common::Painter, :set_rotate)
15
+
16
+ trace(::Shoes::Swt::RectPainter, :fill)
17
+ trace(::Shoes::Swt::RectPainter, :draw)
18
+
19
+ trace(::Shoes::Swt::TextBlock::Painter, :paintControl)
20
+ trace(::Shoes::Swt::TextBlock::Painter, :draw_layouts)
21
+
22
+ trace(::Shoes::Swt::ColorFactory, :create)
23
+ trace(::Shoes::Swt::ColorFactory, :create_new)
24
+ end
25
+
26
+ def self.trace(clazz, method_name, metric_suffix=method_name)
27
+ clazz.class_eval do
28
+ include NewRelic::Agent::MethodTracer
29
+ add_method_tracer method_name, 'Shoes/#{self.class.name}/' + metric_suffix.to_s
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,56 @@
1
+ module NewRelic
2
+ module Shoes
3
+ class Reporter
4
+ HEADER = ["Call", "Count", "Total Time (s)", "Excl. Time (s)", "IPS"]
5
+ def report(io=STDOUT)
6
+ metrics = NewRelic::Agent.instance.stats_engine.harvest!
7
+ results = [HEADER]
8
+
9
+ append_to_results(metrics, results)
10
+ max_width = max_width_from(results)
11
+ print_results(io, results, max_width)
12
+ end
13
+
14
+ def append_to_results(metrics, results)
15
+ results.concat(metrics.map do |spec, stats|
16
+ [
17
+ spec.name,
18
+ stats.call_count.to_s,
19
+ stats.total_call_time.round(6).to_s,
20
+ stats.total_exclusive_time.round(6).to_s,
21
+ ips_from_stats(stats).round.to_s
22
+ ]
23
+ end)
24
+ end
25
+
26
+ def ips_from_stats(stats)
27
+ if stats.total_call_time > 0 && stats.call_count > 0
28
+ (1.0/(stats.total_call_time/stats.call_count))
29
+ else
30
+ 0.0
31
+ end
32
+ end
33
+
34
+ def max_width_from(results)
35
+ results.inject([]) do |memo, row|
36
+ row.each_with_index do |column, index|
37
+ if memo[index].nil? || memo[index] < column.length
38
+ memo[index] = column.length
39
+ end
40
+ end
41
+ memo
42
+ end
43
+ end
44
+
45
+ def print_results(io, results, max_width)
46
+ results.each do |row|
47
+ row.each_with_index do |column, index|
48
+ io.print column
49
+ io.print " " * (max_width[index] - column.length + 2)
50
+ end
51
+ io.print "\n"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ module NewRelic
2
+ module Shoes
3
+ VERSION = "0.1.0"
4
+ end
5
+ 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 'newrelic/shoes/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "newrelic-shoes"
8
+ spec.version = NewRelic::Shoes::VERSION
9
+ spec.authors = ["Jason R. Clark"]
10
+ spec.email = ["jason@jasonclark.net"]
11
+
12
+ spec.summary = %q{Use New Relic to trace Shoes.}
13
+ spec.homepage = "https://github.com/jasonrclark/newrelic-shoes."
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "newrelic_rpm"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.8"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic-shoes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason R. Clark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ name: newrelic_rpm
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.8'
33
+ name: bundler
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ name: rake
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - jason@jasonclark.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/newrelic/shoes.rb
72
+ - lib/newrelic/shoes/instrumentation.rb
73
+ - lib/newrelic/shoes/reporter.rb
74
+ - lib/newrelic/shoes/version.rb
75
+ - newrelic-shoes.gemspec
76
+ homepage: https://github.com/jasonrclark/newrelic-shoes.
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Use New Relic to trace Shoes.
100
+ test_files: []
101
+ has_rdoc: