allocation_tracer 0.1.0 → 0.1.1

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: cc70bffa355bef7e53d7dec123a601142634004e
4
- data.tar.gz: e3d1ac0a14f14e890491aacb26601d9a4bdb564f
3
+ metadata.gz: 434fc304eec817d33faa852fed47fe0313b5ac3a
4
+ data.tar.gz: ec7b3a9e1f126cfaf7cbff508b9613eb93547334
5
5
  SHA512:
6
- metadata.gz: d9b6df363aa685702c53a24386a76e6d1ea023e216551a4fe7e30a9df82722457857e84ed94d8ce17cdea3aacaa77c94578330be6350e12c1e68636af8a4939b
7
- data.tar.gz: 028466e6747249427b595a0d106891cdbc93add1f4b0ca29e92f4512b47663800413743ad893ebfa90a8645aafafb9afc001aa9f3d5e35fad4fd2ebe151732f1
6
+ metadata.gz: eeb8744fbad790fada8a84f78cb83c6d58c1dd62044125a21f6770f77392c22a9d2400fa13814eaf7f6a8f76fbc8da125bb56942500a78c1e474c3333aaac6c5
7
+ data.tar.gz: 5c7baa58e8f347acd5d873112d1f9fe6ee3ce84e55b626cfbcd2d61d48c7cf10a49e10a39d6692044d549ae168ac36c70005b1108a9c1a43a947d8cdbca328f9
@@ -139,7 +139,7 @@ get_traceobj_arg(void)
139
139
  tmp_trace_arg = ALLOC_N(struct traceobj_arg, 1);
140
140
  tmp_trace_arg->running = 0;
141
141
  tmp_trace_arg->keys = 0;
142
- tmp_trace_arg->vals = VAL_COUNT | VAL_TOTAL_AGE | VAL_MAX_AGE | VAL_MIN_AGE | VAL_MEMSIZE;
142
+ tmp_trace_arg->vals = VAL_COUNT | VAL_OLDCOUNT | VAL_TOTAL_AGE | VAL_MAX_AGE | VAL_MIN_AGE | VAL_MEMSIZE;
143
143
  tmp_trace_arg->aggregate_table = st_init_table(&memcmp_hash_type);
144
144
  tmp_trace_arg->object_table = st_init_numtable();
145
145
  tmp_trace_arg->str_table = st_init_strtable();
@@ -536,22 +536,27 @@ allocation_tracer_setup(int argc, VALUE *argv, VALUE self)
536
536
  rb_raise(rb_eRuntimeError, "can't change configuration during running");
537
537
  }
538
538
  else {
539
- int i;
540
- VALUE ary = rb_check_array_type(argv[0]);
541
-
542
- arg->keys = 0;
543
-
544
- for (i=0; i<(int)RARRAY_LEN(ary); i++) {
545
- if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("path"))) arg->keys |= KEY_PATH;
546
- else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("line"))) arg->keys |= KEY_LINE;
547
- else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("type"))) arg->keys |= KEY_TYPE;
548
- else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("class"))) arg->keys |= KEY_CLASS;
549
- else {
550
- rb_raise(rb_eArgError, "not supported key type");
539
+ if (argc >= 1) {
540
+ int i;
541
+ VALUE ary = rb_check_array_type(argv[0]);
542
+
543
+ arg->keys = 0;
544
+
545
+ for (i=0; i<(int)RARRAY_LEN(ary); i++) {
546
+ if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("path"))) arg->keys |= KEY_PATH;
547
+ else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("line"))) arg->keys |= KEY_LINE;
548
+ else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("type"))) arg->keys |= KEY_TYPE;
549
+ else if (RARRAY_AREF(ary, i) == ID2SYM(rb_intern("class"))) arg->keys |= KEY_CLASS;
550
+ else {
551
+ rb_raise(rb_eArgError, "not supported key type");
552
+ }
551
553
  }
552
554
  }
553
555
  }
554
556
 
557
+ if (argc == 0) {
558
+ arg->keys = KEY_PATH | KEY_LINE;
559
+ }
555
560
  return Qnil;
556
561
  }
557
562
 
@@ -1,3 +1,3 @@
1
1
  module ObjectSpace::AllocationTracer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -82,6 +82,20 @@ describe ObjectSpace::AllocationTracer do
82
82
  expect(result[[__FILE__, line + 1, Object]]).to eq [1, 0, 0, 0, 0, 0]
83
83
  expect(result[[__FILE__, line + 1, String]]).to eq [1, 0, 0, 0, 0, 0]
84
84
  end
85
+
86
+ it 'should have correct headers' do
87
+ ObjectSpace::AllocationTracer.setup(%i(path line))
88
+ expect(ObjectSpace::AllocationTracer.header).to eq [:path, :line, :count, :old_count, :total_age, :min_age, :max_age, :total_memsize]
89
+ ObjectSpace::AllocationTracer.setup(%i(path line class))
90
+ expect(ObjectSpace::AllocationTracer.header).to eq [:path, :line, :class, :count, :old_count, :total_age, :min_age, :max_age, :total_memsize]
91
+ ObjectSpace::AllocationTracer.setup(%i(path line type class))
92
+ expect(ObjectSpace::AllocationTracer.header).to eq [:path, :line, :type, :class, :count, :old_count, :total_age, :min_age, :max_age, :total_memsize]
93
+ end
94
+
95
+ it 'should set default setup' do
96
+ ObjectSpace::AllocationTracer.setup()
97
+ expect(ObjectSpace::AllocationTracer.header).to eq [:path, :line, :count, :old_count, :total_age, :min_age, :max_age, :total_memsize]
98
+ end
85
99
  end
86
100
  end
87
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allocation_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada