Aaron Sherman <[EMAIL PROTECTED]> wrote: > On Wed, 2004-04-28 at 11:33, Dan Sugalski wrote:
> Only one question. What's the performance hit likely to be and is there > any way around that performance hit for code that doesn't want to take > it? As Dan already said there is no performance hit (at least if the MMD tables don't blow the caches). Doing 5 M divide vtables[1] on Athon 800, -O3 build: $ parrot -j mmdp.imc # 10 / 2 PerlInt 1.048340 Integer 1.097163 # left arg MMD, right is VTABLE_get_integer [2] Integer 1.039819 # left+right MMD, both use PMC_int_val(pmc) [3] $ parrot -j mmdp.imc # 10 / 3 PerlInt 1.503322 # LHS type morph to PerlNum Integer 1.039199 The relevant function in integer.pmc has one of the follwing lines inside: static void integer_divide(Parrot_Interp interp, PMC* self, PMC* value, PMC* destination){ INTVAL result; // result = PMC_int_val(self) / VTABLE_get_integer(interp, value); //[2] result = PMC_int_val(self) / PMC_int_val(value); //[3] VTABLE_set_integer_native(interp, destination, result); } leo [1] $ cat mmdp.imc .pcc_sub _main prototyped .const int max = 5000000 .const int val = 3 # or 2 $P0 = new PerlInt $P1 = new PerlInt $P2 = new PerlInt $P1 = 10 $P2 = val .local float start start = time .local int i i = 0 lp1: $P0 = $P1 / $P2 inc i if i < max goto lp1 $N0 = time $N0 -= start print "PerlInt " print $N0 print "\n" $P0 = new Integer $P1 = new Integer $P2 = new Integer $P1 = 10 $P2 = val .local float start start = time .local int i i = 0 lp2: $P0 = $P1 / $P2 inc i if i < max goto lp2 $N0 = time $N0 -= start print "Integer " print $N0 print "\n" end .end