Class: Sample
- Inherits:
-
Object
- Object
- Sample
- Defined in:
- ext/stats/stats-ruby.c
Instance Method Summary collapse
Instance Method Details
#[](key_arg) ⇒ Object
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'ext/stats/stats-ruby.c', line 675
static VALUE rbsample_get(VALUE self, VALUE key_arg)
{
struct rb_sample_data *sd = NULL;
int i;
char counter_name[MAX_COUNTER_KEY_LENGTH+1], *key;
long long val;
Check_Type(key_arg,T_STRING);
Data_Get_Struct(self, struct rb_sample_data, sd);
key = StringValueCStr(key_arg);
for (i = 0; i < sd->cl->cl_count; i++)
{
counter_get_key(sd->cl->cl_ctr[i],counter_name,MAX_COUNTER_KEY_LENGTH+1);
if (strcmp(key, counter_name) == 0)
{
val = stats_sample_get_value(sd->sample, i);
return LONG2FIX(val);
}
}
return Qnil;
}
|
#count ⇒ Object
666 667 668 669 670 671 672 673 |
# File 'ext/stats/stats-ruby.c', line 666
static VALUE rbsample_count(VALUE self)
{
struct rb_sample_data *sd = NULL;
Data_Get_Struct(self, struct rb_sample_data, sd);
return LONG2FIX(sd->cl->cl_count);
}
|
#each ⇒ Object
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
# File 'ext/stats/stats-ruby.c', line 700
static VALUE rbsample_each(VALUE self)
{
struct rb_sample_data *sd = NULL;
int i;
char counter_name[MAX_COUNTER_KEY_LENGTH+1];
long long val;
VALUE key;
Data_Get_Struct(self, struct rb_sample_data, sd);
for (i = 0; i < sd->cl->cl_count; i++)
{
counter_get_key(sd->cl->cl_ctr[i],counter_name,MAX_COUNTER_KEY_LENGTH+1);
key = rb_str_new_cstr(counter_name);
val = stats_sample_get_value(sd->sample, i);
rb_yield_values(2, key, LONG2FIX(val));
}
return self;
}
|
#keys ⇒ Object
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File 'ext/stats/stats-ruby.c', line 635
static VALUE rbsample_keys(VALUE self)
{
struct rb_sample_data *sd = NULL;
VALUE keys;
int i;
char counter_name[MAX_COUNTER_KEY_LENGTH+1];
Data_Get_Struct(self, struct rb_sample_data, sd);
keys = rb_ary_new();
if (keys != Qnil)
{
for (i = 0; i < sd->cl->cl_count; i++)
{
counter_get_key(sd->cl->cl_ctr[i],counter_name,MAX_COUNTER_KEY_LENGTH+1);
rb_ary_push(keys, rb_str_new_cstr(counter_name));
}
}
return keys;
}
|
#time ⇒ Object
657 658 659 660 661 662 663 664 |
# File 'ext/stats/stats-ruby.c', line 657
static VALUE rbsample_time(VALUE self)
{
struct rb_sample_data *sd = NULL;
Data_Get_Struct(self, struct rb_sample_data, sd);
return LONG2FIX(sd->sample->sample_time);
}
|