app_profiler 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e470d5d476934d052b8f5229cea27500fd089d46228458bee9caccd6147d4fdc
4
- data.tar.gz: a7087d13e92ccb0f709bd566c171395bcbc7a3a4d3cdd840cdaf54b712f371f2
3
+ metadata.gz: b93daeac19342da210b998d381259941dc1d12c96fa5d58097423d86b32c03f3
4
+ data.tar.gz: d7b50f279a8b197ba847363db5a6e92b394ac506804d9a499c519dcd36b6071c
5
5
  SHA512:
6
- metadata.gz: e87134e41f02914bce8da256ab75e11eb160dee8dfe05121aff17c9f537c71af68c832efa750ab4713b3d5365f51fa08938e678f434e04fc9de4b6b830d870ce
7
- data.tar.gz: fa2d66d349c5328ad24a6fac732ab04dd67fe77184ac32f680d55f06b204deaf0d08412d42abf87a627e25250bb9a442d6474c8a197e696494f8a6cc5d99e221
6
+ metadata.gz: d996e6faf3bb8c02e8f34e462d3c74beac53d656d188330972ecba83770524b42dbc36132aa8b6e2cadd57fe0b6b5504a548a1d96ae58b3e7e14ac504d672f2e
7
+ data.tar.gz: 124bc292cff5decf4cdf7f7d4b8b22cc2820123a1fbda5f56970a1fd76da74675e68dbb5a953024c778eb64bb5c9a7ff8b41f0a62be5dcbdd0f6e214a7cc8fc7
data/lib/app_profiler.rb CHANGED
@@ -24,7 +24,7 @@ module AppProfiler
24
24
  autoload :Profiler, "app_profiler/profiler"
25
25
  autoload :Profile, "app_profiler/profile"
26
26
 
27
- mattr_accessor :logger
27
+ mattr_accessor :logger, default: Logger.new($stdout)
28
28
  mattr_accessor :root
29
29
  mattr_accessor :profile_root
30
30
 
@@ -43,6 +43,15 @@ module AppProfiler
43
43
  Profiler.run(*args, &block)
44
44
  end
45
45
 
46
+ def start(*args)
47
+ Profiler.start(*args)
48
+ end
49
+
50
+ def stop
51
+ Profiler.stop
52
+ Profiler.results
53
+ end
54
+
46
55
  def profile_header=(profile_header)
47
56
  @@profile_header = profile_header # rubocop:disable Style/ClassVars
48
57
  @@request_profile_header = nil # rubocop:disable Style/ClassVars
@@ -24,21 +24,6 @@ module AppProfiler
24
24
  stop if started
25
25
  end
26
26
 
27
- def results
28
- stackprof_profile = stackprof_results
29
-
30
- return unless stackprof_profile
31
-
32
- Profile.from_stackprof(stackprof_profile)
33
- rescue => error
34
- AppProfiler.logger.info(
35
- "[Profiler] failed to obtain the profile error_class=#{error.class} error_message=#{error.message}"
36
- )
37
- nil
38
- end
39
-
40
- private
41
-
42
27
  def start(params = {})
43
28
  # Do not start the profiler if StackProf was started somewhere else.
44
29
  return false if running?
@@ -59,6 +44,21 @@ module AppProfiler
59
44
  StackProf.stop
60
45
  end
61
46
 
47
+ def results
48
+ stackprof_profile = stackprof_results
49
+
50
+ return unless stackprof_profile
51
+
52
+ Profile.from_stackprof(stackprof_profile)
53
+ rescue => error
54
+ AppProfiler.logger.info(
55
+ "[Profiler] failed to obtain the profile error_class=#{error.class} error_message=#{error.message}"
56
+ )
57
+ nil
58
+ end
59
+
60
+ private
61
+
62
62
  def stackprof_results
63
63
  StackProf.results
64
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppProfiler
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.7"
5
5
  end
@@ -14,6 +14,7 @@ module AppProfiler
14
14
  end
15
15
 
16
16
  def initialize(profile)
17
+ super()
17
18
  @profile = profile
18
19
  end
19
20
 
@@ -36,7 +37,7 @@ module AppProfiler
36
37
  # We currently only support this gem in the root Gemfile.
37
38
  # See https://github.com/Shopify/app_profiler/issues/15
38
39
  # for more information
39
- yarn("add --dev --ignore-workspace-root-check speedscope")
40
+ yarn("add --dev --ignore-workspace-root-check speedscope") unless speedscope_added?
40
41
  end
41
42
 
42
43
  def ensure_yarn_installed
@@ -56,6 +57,10 @@ module AppProfiler
56
57
  AppProfiler.root.join("package.json").exist?
57
58
  end
58
59
 
60
+ def speedscope_added?
61
+ AppProfiler.root.join("node_modules/speedscope").exist?
62
+ end
63
+
59
64
  def exec(command)
60
65
  system(command).tap do |return_code|
61
66
  yield unless return_code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gannon McGibbon
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2020-07-08 00:00:00.000000000 Z
16
+ date: 2021-02-19 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport