Here is a small statistic about method call frequency, its generated
from an mcs compilation run (patch to generate the info is attached).

Method call frequency distribution:
 #calls <=               1        242  14.9%  14.9%

14.9% of all methods are only called once

 #calls <=               2         99  6.1%  21.0%
 #calls <=               4         78  4.8%  25.8%
 #calls <=               8         87  5.4%  31.2%
 #calls <=              16        103  6.3%  37.5%
 #calls <=              32         69  4.2%  41.7%
 #calls <=              64         42  2.6%  44.3%
 #calls <=             128        147  9.1%  53.4%

53.4% of all methods are called less than 128 times 

 #calls <=             256         70  4.3%  57.7%
 #calls <=             512         75  4.6%  62.3%
 #calls <=            1024        118  7.3%  69.6%
 #calls <=            2048        102  6.3%  75.9%
 #calls <=            4096         95  5.8%  81.7%
 #calls <=            8192         85  5.2%  86.9%
 #calls <=           16384         69  4.2%  91.2%
 #calls <=           32768         51  3.1%  94.3%
 #calls <=           65536         37  2.3%  96.6%
 #calls <=          131072         26  1.6%  98.2%
 #calls <=          262144         15  0.9%  99.1%
 #calls <=          524288          9  0.6%  99.7%
 #calls <=         1048576          5  0.3%  100.0%
 #calls <=         2097152          0  0.0%  100.0%
 #calls <=         4194304          0  0.0%  100.0%
 #calls <=         8388608          0  0.0%  100.0%
 #calls <=        16777216          0  0.0%  100.0%
 #calls <=        33554432          0  0.0%  100.0%
 #calls <=        67108864          0  0.0%  100.0%
 #calls <=       134217728          0  0.0%  100.0%
 #calls <=       268435456          0  0.0%  100.0%
 #calls <=       536870912          0  0.0%  100.0%
 #calls <=      1073741824          0  0.0%  100.0%
 #calls <=      2147483648          0  0.0%  100.0%



? metadata/monosn
? tests/stest.dat
Index: metadata/profiler.c
===================================================================
RCS file: /cvs/public/mono/mono/metadata/profiler.c,v
retrieving revision 1.6
diff -u -r1.6 profiler.c
--- metadata/profiler.c 24 Aug 2002 17:29:06 -0000      1.6
+++ metadata/profiler.c 19 Sep 2002 14:30:01 -0000
@@ -2,6 +2,7 @@
 #include "mono/metadata/profiler-private.h"
 #include "mono/metadata/debug-helpers.h"
 #include <string.h>
+#include <math.h>
 
 static MonoProfiler * current_profiler = NULL;
 
@@ -479,12 +480,25 @@
        char buf [256];
        char *sig;
        guint64 total_calls = 0;
+       int cbuf [64];
+       int i, nfunc = 0, idx;
+       float sum = 0.0;
 
+       for (i = 0; i < 32; i++) cbuf [i] = 0;
+       
        if (funcs)
                g_print ("Method name\t\t\t\t\tTotal (ms) Calls Per call (ms)\n");
        for (tmp = funcs; tmp; tmp = tmp->next) {
                p = tmp->data;
                total_calls += p->count;
+
+               nfunc++;
+
+               idx = (int)log2 ((double)p->count);
+
+               cbuf [idx]++;
+               //printf ("TEST1 %llu %d %d %g\n", p->count, idx, cbuf [idx], log2 
+((double)4.0));
+
                if (!(gint)(p->total*1000))
                        continue;
                sig = mono_signature_get_desc (p->u.method->signature, FALSE);
@@ -496,6 +510,13 @@
                        (double)(p->total*1000), p->count, 
(double)(p->total*1000)/(double)p->count);
        }
        printf ("Total number of calls: %lld\n", total_calls);
+
+       printf ("Method call frequency distribution\n");
+       for (i = 0; i < 32; i++) {
+               float rel = (cbuf [i]*100.0)/(float)nfunc;
+               sum += rel;
+               printf (" #calls <= %15u %10u  %2.1f%%  %2.1f%%\n", 1<<(i+1) - 1, cbuf 
+[i], rel, sum);
+       }
 }
 
 typedef struct {

Reply via email to