Module: GC::Tracker
- Defined in:
- ext/gctrack/gctrack.c
Class Method Summary collapse
-
.GC::Tracker.disable ⇒ Boolean
Globally disables the tracker.
-
.GC::Tracker.enable ⇒ Boolean
Globally enables the tracker.
-
.GC::Tracker.enabled? ⇒ Boolean
Returns
trueif the Tracker is enabled,falseotherwise. -
.GC::Tracker.end_record ⇒ Array?
Ends the recording of the last started record and return the the collected information.
-
.GC::Tracker.start_record ⇒ Boolean
Starts recording GC cycles and their duration.
Class Method Details
.GC::Tracker.disable ⇒ Boolean
Globally disables the tracker. Returns true if the Tracker is disabled after this call (whether it disabled it or not), false otherwise.
GC::Tracker.enabled? # true
GC::Tracker.disable # true
GC::Tracker.enabled? # false
GC::Tracker.disable # true
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'ext/gctrack/gctrack.c', line 225 static VALUE gctracker_disable(VALUE self) { if (!gctracker_enabled()) { return Qtrue; } rb_tracepoint_disable(tracepoint); if (gctracker_enabled()) { return Qfalse; } return Qtrue; } |
.GC::Tracker.enable ⇒ Boolean
Globally enables the tracker. Returns true if the Tracker is enabled after this call (whether it enabled it or not), false otherwise.
GC::Tracker.disable # true
GC::Tracker.enabled? # false
GC::Tracker.enable # true
GC::Tracker.enabled? # true
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'ext/gctrack/gctrack.c', line 192 static VALUE gctracker_enable(int argc, VALUE *argv, VALUE klass) { if (gctracker_enabled()) { return Qtrue; } if (NIL_P(tracepoint)) { if(!create_tracepoint()) { return Qfalse; } } rb_tracepoint_enable(tracepoint); if (!gctracker_enabled()) { return Qfalse; } return Qtrue; } |
.GC::Tracker.enabled? ⇒ Boolean
Returns true if the Tracker is enabled, false otherwise.
GC::Tracker.enabled? # false
GC::Tracker.enable # true
GC::Tracker.enabled? # true
GC::Tracker.enable # true
174 175 176 177 178 |
# File 'ext/gctrack/gctrack.c', line 174 static VALUE gctracker_enabled_p(int argc, VALUE *argv, VALUE klass) { return gctracker_enabled() ? Qtrue : Qfalse; } |
.GC::Tracker.end_record ⇒ Array?
Ends the recording of the last started record and return the the collected information. The array contains two numbers: The amount of GC cycles observed and the cumulative duration in nanoseconds of these cycles. If multiple recordings were started they will be be popped from the stack of records and their values will be returned. GC data gathered is in all records of the stack.
GC::Tracker.start_record # true
GC::Tracker.start_record # true
GC::Tracker.end_record # [2, 12654] amount of cycles and duration since the second #start_record
GC::Tracker.end_record # [3, 15782] GC data since the first #start_record, including the data above
GC::Tracker.disable # true
GC::Tracker.start_record # false
GC::Tracker.end_record # nil
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'ext/gctrack/gctrack.c', line 140 static VALUE gctracker_end_record(int argc, VALUE *argv, VALUE klass) { if (!last_record) { return Qnil; } record_t *record = last_record; last_record = record->parent; if (last_record) { last_record->cycles += record->cycles; last_record->duration += record->duration; } VALUE stats = rb_ary_new2(2); rb_ary_store(stats, 0, ULONG2NUM(record->cycles)); rb_ary_store(stats, 1, ULONG2NUM(record->duration)); free(record); return stats; } |
.GC::Tracker.start_record ⇒ Boolean
Starts recording GC cycles and their duration. Returns true if the recording was started, false otherwise. If the record could be started an GC::Tracker#end_record invocation will always return data for the record, otherwise that invocation would return nil. One case where false would be returned is if the Tracker isn’t enabled. #start_record can be nested. These records will have a parent-child relationship, where the parent will contain all GC data of the child.
GC::Tracker.enabled? # true
GC::Tracker.start_record # true
GC::Tracker.start_record # true
GC::Tracker.end_record # [2, 12654] from the second #start_record
GC::Tracker.disable # true
GC::Tracker.start_record # false
GC::Tracker.end_record # [3, 15782] from the first #start_record, contains the data from the first record
GC::Tracker.end_record # nil from the last #start_record, that returned false
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'ext/gctrack/gctrack.c', line 103 static VALUE gctracker_start_record(int argc, VALUE *argv, VALUE klass) { if(!gctracker_enabled()) { return Qfalse; } record_t *record = (record_t *) calloc(1, sizeof(record_t)); if (!record) { return Qfalse; } record->parent = last_record; last_record = record; return Qtrue; } |