[Mono-list] Method call frequency distribution

Dietmar Maurer dietmar@ximian.com
19 Sep 2002 16:54:26 +0200


--=-YmSBJVl3qxXq1qmqUUFU
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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%




--=-YmSBJVl3qxXq1qmqUUFU
Content-Disposition: attachment; filename=mono.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=mono.diff; charset=ISO-8859-15

? metadata/monosn
? tests/stest.dat
Index: metadata/profiler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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>
=20
 static MonoProfiler * current_profiler =3D NULL;
=20
@@ -479,12 +480,25 @@
 	char buf [256];
 	char *sig;
 	guint64 total_calls =3D 0;
+	int cbuf [64];
+	int i, nfunc =3D 0, idx;
+	float sum =3D 0.0;
=20
+	for (i =3D 0; i < 32; i++) cbuf [i] =3D 0;
+=09
 	if (funcs)
 		g_print ("Method name\t\t\t\t\tTotal (ms) Calls Per call (ms)\n");
 	for (tmp =3D funcs; tmp; tmp =3D tmp->next) {
 		p =3D tmp->data;
 		total_calls +=3D p->count;
+
+		nfunc++;
+
+		idx =3D (int)log2 ((double)p->count);
+
+		cbuf [idx]++;
+		//printf ("TEST1 %llu %d %d %g\n", p->count, idx, cbuf [idx], log2 ((dou=
ble)4.0));
+
 		if (!(gint)(p->total*1000))
 			continue;
 		sig =3D 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->c=
ount);
 	}
 	printf ("Total number of calls: %lld\n", total_calls);
+
+	printf ("Method call frequency distribution\n");
+	for (i =3D 0; i < 32; i++) {
+		float rel =3D (cbuf [i]*100.0)/(float)nfunc;
+		sum +=3D rel;
+		printf (" #calls <=3D %15u %10u  %2.1f%%  %2.1f%%\n", 1<<(i+1) - 1, cbuf=
 [i], rel, sum);
+	}
 }
=20
 typedef struct {

--=-YmSBJVl3qxXq1qmqUUFU--