gc_tracer 1.0.3 → 1.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: 477d54ed3c9678407cf4cdb090080222048716f6
4
- data.tar.gz: 1c45e0a9ae7ff7f95c5d670835d784c5bef79328
3
+ metadata.gz: b9ce36d7506d6380617767354fcf92f131fb8eb2
4
+ data.tar.gz: cd6eeb8447b71f3e4ceafd623af6bf0e793c45a7
5
5
  SHA512:
6
- metadata.gz: ff98def642484926e33a0116e12a1bec60cb06daccafd798505ac14f17918662c3ffa0f19d6d87fc28e8974b4077b7482d04969e0bbcbd5c54da4ffa14a67cf3
7
- data.tar.gz: f9108f5902479a5d559ed40b16b074036b29f6b65abcc62816046060978aec449307bc424d611637ed1e7ebb1058c5706e09d93e54ac74819b5920f082df8f4f
6
+ metadata.gz: 28c17973fe087d97552e5b12d0e8e0a3b43e0910e2591ae9144d3e6225bdd008da490777939b7d2cd97582a2fbc7e907b18b4c2517869fa65cad7ffb36fc1b66
7
+ data.tar.gz: b27a89753bf65de227143b1e5966e131e5c47cc595cd90332f0265fa6c6bd28a35febfc5306fa7b0615dd93ae6c8aeeaa9c61db034eadcdb85beeaa867c64808
data/README.md CHANGED
@@ -48,6 +48,8 @@ ensure
48
48
  end
49
49
  ```
50
50
 
51
+ ### Setup
52
+
51
53
  In the stored file (filename), you can get tab separated values of:
52
54
 
53
55
  * `GC.stat()`
@@ -100,6 +102,28 @@ and :nano_time (if platform supports clock_gettime()).
100
102
 
101
103
  See lib/gc_tracer.rb for more details.
102
104
 
105
+ ### Custom events
106
+
107
+ You can add custom events by your own. Calling
108
+ `GC::Tracer.custom_event_logging(event_name)` in your program will puts
109
+ new statistics line into the logging file.
110
+
111
+ For example, the following program insert 1000 custom event lines into
112
+ logging file (stderr for this type).
113
+
114
+ ```ruby
115
+ GC::Tracer.start_logging(events: %i(start), gc_stat: false) do
116
+ 1_000.times{|i|
117
+ 1_000.times{''}
118
+ GC::Tracer.custom_event_logging("custom_#{i}")
119
+ }
120
+ end
121
+ ```
122
+
123
+ This method is useful to trace where the GC events occur in your
124
+ application.
125
+
126
+
103
127
  ## Contributing
104
128
 
105
129
  1. Fork it ( http://github.com/ko1/gc_tracer/fork )
@@ -289,13 +289,13 @@ out_rusage(struct gc_logging *logging)
289
289
  }
290
290
 
291
291
  static void
292
- logging_start_i(VALUE tpval, struct gc_logging *logging)
292
+ out_stat(struct gc_logging *logging, const char *event)
293
293
  {
294
294
  #if HAVE_GETRUSAGE
295
295
  logging->filled_rusage = 0;
296
296
  #endif
297
297
 
298
- out_str(logging->out, logging->event);
298
+ out_str(logging->out, event);
299
299
  (logging->config.out_time_func)(logging->out);
300
300
 
301
301
  if (logging->config.log_gc_stat) out_gc_stat(logging);
@@ -306,6 +306,12 @@ logging_start_i(VALUE tpval, struct gc_logging *logging)
306
306
  out_terminate(logging->out);
307
307
  }
308
308
 
309
+ static void
310
+ logging_start_i(VALUE tpval, struct gc_logging *logging)
311
+ {
312
+ out_stat(logging, logging->event);
313
+ }
314
+
309
315
  static void
310
316
  out_header_each(struct gc_logging *logging, VALUE *syms, int n)
311
317
  {
@@ -562,6 +568,21 @@ gc_tracer_stop_logging(VALUE self)
562
568
  return self;
563
569
  }
564
570
 
571
+ static VALUE
572
+ gc_tracer_custom_event_logging(VALUE self, VALUE event_str)
573
+ {
574
+ struct gc_logging *logging = &trace_logging;
575
+ const char *str = StringValueCStr(event_str);
576
+
577
+ if (logging->enabled) {
578
+ out_stat(logging, str);
579
+ }
580
+ else {
581
+ rb_raise(rb_eRuntimeError, "GC tracer is not enabled.");
582
+ }
583
+ return self;
584
+ }
585
+
565
586
  void
566
587
  Init_gc_tracer_logging(VALUE mod)
567
588
  {
@@ -576,6 +597,9 @@ Init_gc_tracer_logging(VALUE mod)
576
597
  rb_define_module_function(mod, "setup_logging_gc_latest_gc_info=", gc_tracer_setup_logging_gc_latest_gc_info, 1);
577
598
  rb_define_module_function(mod, "setup_logging_rusage=", gc_tracer_setup_logging_rusage, 1);
578
599
 
600
+ /* custom event */
601
+ rb_define_module_function(mod, "custom_event_logging", gc_tracer_custom_event_logging, 1);
602
+
579
603
  /* setup data */
580
604
  setup_gc_trace_symbols();
581
605
  create_gc_hooks();
@@ -1,3 +1,3 @@
1
1
  module GC::Tracer
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gc_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler