Class: PerfTools::CpuProfiler

Inherits:
Object
  • Object
show all
Defined in:
ext/perftools.c

Class Method Summary collapse

Class Method Details

.running?Boolean

Returns:

  • (Boolean)


82
83
84
85
86
# File 'ext/perftools.c', line 82

VALUE
cpuprofiler_running_p(VALUE self)
{
  return bProfilerRunning;
}

.start(filename) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'ext/perftools.c', line 100

VALUE
cpuprofiler_start(VALUE self, VALUE filename)
{
  StringValue(filename);

  if (bProfilerRunning)
    return Qfalse;

  ProfilerStart(RSTRING_PTR(filename));
  bProfilerRunning = Qtrue;

  if (rb_block_given_p()) {
    rb_yield(Qnil);
    cpuprofiler_stop(self);
  }

  return Qtrue;
}

.stopObject



88
89
90
91
92
93
94
95
96
97
98
# File 'ext/perftools.c', line 88

VALUE
cpuprofiler_stop(VALUE self)
{
  if (!bProfilerRunning)
    return Qfalse;

  bProfilerRunning = Qfalse;
  ProfilerStop();
  ProfilerFlush();
  return Qtrue;
}