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
true
if the Tracker is enabled,false
otherwise. -
.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
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'ext/gctrack/gctrack.c', line 224
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
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'ext/gctrack/gctrack.c', line 191
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
173 174 175 176 177 |
# File 'ext/gctrack/gctrack.c', line 173
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
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'ext/gctrack/gctrack.c', line 144
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;
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
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'ext/gctrack/gctrack.c', line 107
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;
}
|