Class: Fiber::Profiler::Capture
- Inherits:
-
Object
- Object
- Fiber::Profiler::Capture
- Defined in:
- lib/fiber/profiler/capture.rb,
ext/fiber/profiler/capture.c
Overview
Represents a running profiler capture.
Class Method Summary collapse
Instance Method Summary collapse
- #filter_threshold ⇒ Object
- #initialize(*args) ⇒ Object constructor
- #sample_rate ⇒ Object
- #stall_threshold ⇒ Object
- #stalls ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #track_calls ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'ext/fiber/profiler/capture.c', line 269
VALUE Fiber_Profiler_Capture_initialize(int argc, VALUE *argv, VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
VALUE arguments[5] = {0};
VALUE options = Qnil;
rb_scan_args(argc, argv, ":", &options);
rb_get_kwargs(options, Fiber_Profiler_Capture_initialize_options, 0, 5, arguments);
if (arguments[0] != Qundef) {
capture->stall_threshold = NUM2DBL(arguments[0]);
}
if (arguments[1] != Qundef) {
capture->filter_threshold = NUM2DBL(arguments[1]);
}
if (arguments[2] != Qundef) {
capture->track_calls = RB_TEST(arguments[2]);
}
if (arguments[3] != Qundef) {
capture->sample_rate = NUM2DBL(arguments[3]);
}
if (arguments[4] != Qundef) {
Fiber_Profiler_Capture_output_set(capture, arguments[4]);
} else {
// Initialize the profiler output - we dup `rb_stderr` because the profiler may otherwise run into synchronization issues with other uses of `rb_stderr`:
Fiber_Profiler_Capture_output_set(capture, rb_obj_dup(rb_stderr));
}
return self;
}
|
Class Method Details
.default ⇒ Object
303 304 305 306 307 308 309 310 311 312 |
# File 'ext/fiber/profiler/capture.c', line 303
VALUE Fiber_Profiler_Capture_default(VALUE klass) {
if (!Fiber_Profiler_capture_p) {
return Qnil;
}
VALUE capture = Fiber_Profiler_Capture_allocate(klass);
Fiber_Profiler_Capture_initialize(0, NULL, capture);
return capture;
}
|
Instance Method Details
#filter_threshold ⇒ Object
801 802 803 804 805 |
# File 'ext/fiber/profiler/capture.c', line 801
static VALUE Fiber_Profiler_Capture_filter_threshold_get(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
return DBL2NUM(capture->filter_threshold);
}
|
#sample_rate ⇒ Object
819 820 821 822 823 |
# File 'ext/fiber/profiler/capture.c', line 819
static VALUE Fiber_Profiler_Capture_sample_rate_get(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
return DBL2NUM(capture->sample_rate);
}
|
#stall_threshold ⇒ Object
795 796 797 798 799 |
# File 'ext/fiber/profiler/capture.c', line 795
static VALUE Fiber_Profiler_Capture_stall_threshold_get(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
return DBL2NUM(capture->stall_threshold);
}
|
#stalls ⇒ Object
813 814 815 816 817 |
# File 'ext/fiber/profiler/capture.c', line 813
static VALUE Fiber_Profiler_Capture_stalls_get(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
return SIZET2NUM(capture->stalls);
}
|
#start ⇒ Object
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'ext/fiber/profiler/capture.c', line 521
VALUE Fiber_Profiler_Capture_start(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
if (capture->running) return Qfalse;
capture->running = 1;
capture->thread = rb_thread_current();
Fiber_Profiler_Capture_reset(capture);
Fiber_Profiler_Time_current(&capture->start_time);
rb_thread_add_event_hook(capture->thread, Fiber_Profiler_Capture_fiber_switch_callback, RUBY_EVENT_FIBER_SWITCH, self);
return self;
}
|
#stop ⇒ Object
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'ext/fiber/profiler/capture.c', line 537
VALUE Fiber_Profiler_Capture_stop(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
if (!capture->running) return Qfalse;
Fiber_Profiler_Capture_pause(self);
rb_thread_remove_event_hook_with_data(capture->thread, Fiber_Profiler_Capture_fiber_switch_callback, self);
capture->running = 0;
capture->thread = Qnil;
Fiber_Profiler_Capture_reset(capture);
return self;
}
|
#track_calls ⇒ Object
807 808 809 810 811 |
# File 'ext/fiber/profiler/capture.c', line 807
static VALUE Fiber_Profiler_Capture_track_calls_get(VALUE self) {
struct Fiber_Profiler_Capture *capture = Fiber_Profiler_Capture_get(self);
return capture->track_calls ? Qtrue : Qfalse;
}
|