diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-25 04:10:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-25 04:10:55 +0000 |
commit | 5bda3debcf2493308afd8d5c7d5ee306d5980828 (patch) | |
tree | 96b9cd171bfef56dee38199674d82e57444a2abe /ext | |
parent | abcbd7ea38f64f942a934ba065aabf9da81a21bc (diff) | |
download | ruby-5bda3debcf2493308afd8d5c7d5ee306d5980828.tar.gz |
* ext/probeprofiler: set eol-style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/probeprofiler/extconf.rb | 4 | ||||
-rw-r--r-- | ext/probeprofiler/lib/probeprofile.rb | 14 | ||||
-rw-r--r-- | ext/probeprofiler/lib/probeprofiler.rb | 28 | ||||
-rw-r--r-- | ext/probeprofiler/probeprofiler.c | 126 |
4 files changed, 86 insertions, 86 deletions
diff --git a/ext/probeprofiler/extconf.rb b/ext/probeprofiler/extconf.rb index 1592971d4c..31cfc85c06 100644 --- a/ext/probeprofiler/extconf.rb +++ b/ext/probeprofiler/extconf.rb @@ -1,2 +1,2 @@ -require 'mkmf'
-create_makefile("probeprofiler")
+require 'mkmf' +create_makefile("probeprofiler") diff --git a/ext/probeprofiler/lib/probeprofile.rb b/ext/probeprofiler/lib/probeprofile.rb index f5ff40d2cc..ef722b59da 100644 --- a/ext/probeprofiler/lib/probeprofile.rb +++ b/ext/probeprofiler/lib/probeprofile.rb @@ -1,7 +1,7 @@ -require 'probeprofiler'
-END{
- ProbeProfiler.stop_profile
- ProbeProfiler.print_profile
-}
-
-ProbeProfiler.start_profile
+require 'probeprofiler' +END{ + ProbeProfiler.stop_profile + ProbeProfiler.print_profile +} + +ProbeProfiler.start_profile diff --git a/ext/probeprofiler/lib/probeprofiler.rb b/ext/probeprofiler/lib/probeprofiler.rb index e014adda2f..a00b6df653 100644 --- a/ext/probeprofiler/lib/probeprofiler.rb +++ b/ext/probeprofiler/lib/probeprofiler.rb @@ -1,14 +1,14 @@ -
-require 'probeprofiler.so'
-
-def ProbeProfiler.print_profile
- data = ProbeProfiler.profile_data
- total = 0.0
- printf("%-60s %-8s %-7s\n", "ProbeProfile Result: Method signature", "count", "ratio")
- data.map{|k, n| total += n; [n, k]}.sort.reverse.each{|n, sig|
- #
- printf("%-60s %8d %7.2f%%\n", sig, n, 100 * n / total)
- }
- printf("%60s %8d\n", "total:", total)
-end
-
+ +require 'probeprofiler.so' + +def ProbeProfiler.print_profile + data = ProbeProfiler.profile_data + total = 0.0 + printf("%-60s %-8s %-7s\n", "ProbeProfile Result: Method signature", "count", "ratio") + data.map{|k, n| total += n; [n, k]}.sort.reverse.each{|n, sig| + # + printf("%-60s %8d %7.2f%%\n", sig, n, 100 * n / total) + } + printf("%60s %8d\n", "total:", total) +end + diff --git a/ext/probeprofiler/probeprofiler.c b/ext/probeprofiler/probeprofiler.c index 9d67160bc4..9d2b1a6c09 100644 --- a/ext/probeprofiler/probeprofiler.c +++ b/ext/probeprofiler/probeprofiler.c @@ -1,63 +1,63 @@ -#include <ruby.h>
-#include <yarvcore.h>
-
-static void
-hash_inc(VALUE data, VALUE key)
-{
- VALUE num = INT2FIX(0);
-
- if (num = rb_hash_aref(data, key)) {
- num = INT2FIX(FIX2INT(num) + 1);
- }
-
- rb_hash_aset(data, key, num);
-}
-
-static void
-pprof_hook(rb_event_flag_t flag, VALUE data,
- VALUE dmyid, VALUE dmyklass)
-{
- rb_thread_t *th = GET_THREAD();
- VALUE sig = rb_thread_current_sig(th);
- hash_inc(data, sig);
-}
-
-static VALUE
-pprof_data(VALUE mod)
-{
- rb_const_get_at(mod, rb_intern("#pprof_data"));
-}
-
-static VALUE
-pprof_start(VALUE self)
-{
- VALUE data = pprof_data(self);
- rb_add_event_hook(pprof_hook, RUBY_EVENT_SWITCH, data);
- return Qnil;
-}
-
-static VALUE
-pprof_stop(VALUE self)
-{
- rb_remove_event_hook(pprof_hook);
- return Qnil;
-}
-
-static int
-hash_to_ary_i(VALUE key, VALUE value, VALUE ary)
-{
- rb_ary_push(ary, rb_ary_new3(2, value, key));
- return ST_CONTINUE;
-}
-
-Init_probeprofiler(void)
-{
- VALUE mPProf;
-
- mPProf = rb_define_module("ProbeProfiler");
- rb_const_set(mPProf, rb_intern("#pprof_data"), rb_hash_new());
- rb_define_module_function(mPProf, "start_profile", pprof_start, 0);
- rb_define_module_function(mPProf, "stop_profile", pprof_stop, 0);
- rb_define_module_function(mPProf, "profile_data", pprof_data, 0);
-}
-
+#include <ruby.h> +#include <yarvcore.h> + +static void +hash_inc(VALUE data, VALUE key) +{ + VALUE num = INT2FIX(0); + + if (num = rb_hash_aref(data, key)) { + num = INT2FIX(FIX2INT(num) + 1); + } + + rb_hash_aset(data, key, num); +} + +static void +pprof_hook(rb_event_flag_t flag, VALUE data, + VALUE dmyid, VALUE dmyklass) +{ + rb_thread_t *th = GET_THREAD(); + VALUE sig = rb_thread_current_sig(th); + hash_inc(data, sig); +} + +static VALUE +pprof_data(VALUE mod) +{ + rb_const_get_at(mod, rb_intern("#pprof_data")); +} + +static VALUE +pprof_start(VALUE self) +{ + VALUE data = pprof_data(self); + rb_add_event_hook(pprof_hook, RUBY_EVENT_SWITCH, data); + return Qnil; +} + +static VALUE +pprof_stop(VALUE self) +{ + rb_remove_event_hook(pprof_hook); + return Qnil; +} + +static int +hash_to_ary_i(VALUE key, VALUE value, VALUE ary) +{ + rb_ary_push(ary, rb_ary_new3(2, value, key)); + return ST_CONTINUE; +} + +Init_probeprofiler(void) +{ + VALUE mPProf; + + mPProf = rb_define_module("ProbeProfiler"); + rb_const_set(mPProf, rb_intern("#pprof_data"), rb_hash_new()); + rb_define_module_function(mPProf, "start_profile", pprof_start, 0); + rb_define_module_function(mPProf, "stop_profile", pprof_stop, 0); + rb_define_module_function(mPProf, "profile_data", pprof_data, 0); +} + |