Class: PerfTools::CpuProfiler
- Inherits:
-
Object
- Object
- PerfTools::CpuProfiler
- Defined in:
- ext/perftools.c
Class Method Summary collapse
- .flush ⇒ Object
- .pause ⇒ Object
- .paused? ⇒ Boolean
- .resume ⇒ Object
- .running? ⇒ Boolean
- .start(filename) ⇒ Object
- .stop ⇒ Object
Class Method Details
.flush ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'ext/perftools.c', line 296
static VALUE
cpuprofiler_flush(VALUE self)
{
if (!bProfilerRunning)
return Qfalse;
if (bProfilerPaused)
ProfilerResume();
ProfilerFlush();
if (bProfilerPaused)
ProfilerPause();
return Qtrue;
}
|
.pause ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'ext/perftools.c', line 268
static VALUE
cpuprofiler_pause(VALUE self)
{
if (!bProfilerRunning)
return Qfalse;
if (bProfilerPaused)
return Qfalse;
bProfilerPaused = Qtrue;
ProfilerPause();
return Qtrue;
}
|
.paused? ⇒ Boolean
256 257 258 259 260 |
# File 'ext/perftools.c', line 256
static VALUE
cpuprofiler_paused_p(VALUE self)
{
return bProfilerPaused;
}
|
.resume ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'ext/perftools.c', line 282
static VALUE
cpuprofiler_resume(VALUE self)
{
if (!bProfilerRunning)
return Qfalse;
if (!bProfilerPaused)
return Qfalse;
bProfilerPaused = Qfalse;
ProfilerResume();
return Qtrue;
}
|
.running? ⇒ Boolean
262 263 264 265 266 |
# File 'ext/perftools.c', line 262
static VALUE
cpuprofiler_running_p(VALUE self)
{
return bProfilerRunning;
}
|
.start(filename) ⇒ Object
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'ext/perftools.c', line 329
static VALUE
cpuprofiler_start(VALUE self, VALUE filename)
{
StringValue(filename);
if (bProfilerRunning)
rb_raise(eError, "profiler is already running");
if (getenv("CPUPROFILE_OBJECTS"))
objprofiler_setup();
else if (getenv("CPUPROFILE_METHODS"))
methprofiler_setup();
if (ProfilerStart(RSTRING_PTR(filename))) {
bProfilerRunning = Qtrue;
} else {
rb_raise(eError, "profiler could not be started");
}
if (rb_block_given_p()) {
rb_yield(Qnil);
cpuprofiler_stop(self);
}
return Qtrue;
}
|
.stop ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'ext/perftools.c', line 309
static VALUE
cpuprofiler_stop(VALUE self)
{
if (!bProfilerRunning)
return Qfalse;
bProfilerRunning = Qfalse;
objprofiler_teardown();
methprofiler_teardown();
if (bProfilerPaused)
ProfilerResume();
bProfilerPaused = Qfalse;
ProfilerStop();
ProfilerFlush();
return Qtrue;
}
|