fast_stack 0.0.6 → 0.1.0

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
  SHA1:
3
- metadata.gz: 3762cfda1effa84ee9838599cb87d9a7b700ac41
4
- data.tar.gz: d1d6062254c0ba52a59077c4ba1cd9572c55cce6
3
+ metadata.gz: 25593572df6635a6ab1e50009f6e20617dcf345d
4
+ data.tar.gz: e1c7839628489bc0cc1dceb044b82c7a46493bf9
5
5
  SHA512:
6
- metadata.gz: 3034a0dd8661ad74f004d08028c57b7713c37e59b15b75ac6e0a4da325aeea5d1836b6fd4b87252a2f09f6c49e88b62ea5563488fa12086d291de48aaa6aa7dc
7
- data.tar.gz: 561e72bd7bbdcad54247497fcc6b452bdaa91bf85fc91bf6f3f16bb0c0579999c66e305bf42d93d4643e96d10a485d69168faa3f64b34a02fd67a0f95f1bca31
6
+ metadata.gz: 82b33efbffe61e59052b109eb848697dfada7cac792f871a138c6ff83f3ca1461b4b2f47b59a4d342743e5b32a380d5db8fd524ad5ba35e2bcde4c4870310c0b
7
+ data.tar.gz: 910abe7607c9e1c96ee7444e3a2e9f83c4d88b693385416bed5088a71b84e2d423bfd2faaf19065e173b9a6fc445a0d76d07070be483b00867747e0704742425
data/README.md CHANGED
@@ -18,15 +18,19 @@ Very efficient collection of ruby backtraces, even under heavy CPU load
18
18
  stacks = FastStack.profile do
19
19
  fib(30)
20
20
  end
21
-
21
+
22
22
  puts stacks.count
23
- # 30
24
-
23
+ # 30
24
+
25
25
  ```
26
26
 
27
+ ### Changelog
28
+
29
+ 0.1.0 - 17-Sep - Bugfix - deep callstacks could lead to an infinite loop
30
+
27
31
  ### Notes
28
32
 
29
- This technique was conceived by https://github.com/tmm1 , big thank you.
33
+ This technique was conceived by https://github.com/tmm1 , big thank you.
30
34
 
31
35
  Ruby 2.0 uses #backtrace_locations, 1.9.3 uses #backtrace
32
36
 
@@ -4,7 +4,7 @@
4
4
  #include <ruby/encoding.h>
5
5
 
6
6
  static VALUE
7
- profiler_start(VALUE module, VALUE usec)
7
+ rb_profile_start(VALUE module, VALUE usec)
8
8
  {
9
9
  struct itimerval timer;
10
10
  timer.it_interval.tv_sec = 0;
@@ -16,7 +16,7 @@ profiler_start(VALUE module, VALUE usec)
16
16
  }
17
17
 
18
18
  static VALUE
19
- profiler_stop(VALUE module)
19
+ rb_profile_stop(VALUE module)
20
20
  {
21
21
  struct itimerval timer;
22
22
  memset(&timer, 0, sizeof(timer));
@@ -30,9 +30,9 @@ rb_profile_block(VALUE module, VALUE usec)
30
30
  {
31
31
  rb_need_block();
32
32
 
33
- profiler_start(module, usec);
33
+ rb_profile_start(module, usec);
34
34
  rb_yield(Qundef);
35
- profiler_stop(module);
35
+ rb_profile_stop(module);
36
36
 
37
37
  return Qnil;
38
38
  }
@@ -41,4 +41,6 @@ void Init_fast_stack( void )
41
41
  {
42
42
  VALUE rb_mFastStack = rb_define_module("FastStack");
43
43
  rb_define_module_function(rb_mFastStack, "profile_block", rb_profile_block, 1);
44
+ rb_define_module_function(rb_mFastStack, "stop", rb_profile_stop, 0);
45
+ rb_define_module_function(rb_mFastStack, "start", rb_profile_start, 1);
44
46
  }
data/lib/fast_stack.rb CHANGED
@@ -8,16 +8,15 @@ module FastStack
8
8
  new_api = thread.respond_to?(:backtrace_locations)
9
9
 
10
10
  trap('ALRM') do
11
+ FastStack.stop
11
12
  stack = (new_api ? thread.backtrace_locations : thread.backtrace)
12
13
  # I am not sure if this is ensured to run in the thread
13
- # though in my samples it does
14
+ # though in my samples it always does
14
15
  if thread == Thread.current
15
16
  stack = stack[2..-1]
16
- # since we are in the same thread, might as well remove
17
- # our overhead
18
- start = Time.new
19
17
  end
20
18
  stacks << stack
19
+ FastStack.start(millisecs * 1000)
21
20
  end
22
21
 
23
22
  profile_block(millisecs * 1000, &blk)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-09 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake