Posted to tcl by patthoyts at Thu Jan 10 13:49:28 GMT 2008view pretty

# tcl version
package require Tcl 8.5
puts [time {expr {101**1002}} 100000]

#---------------------------------------------
#perl version
use bigint;
use Benchmark;

my $start = new Benchmark;
my $r = 0;
for (my $n = 0; $n < 100000; $n++) {
  #$r = Math::BigInt::bpow(101,1002);
  $r = 101 ** 1002;
}

my $end = new Benchmark;
my $diff = timediff($end, $start);
print "Time is ", timestr($diff, 'all'), "seconds";

#---------------------------------------------
# tcl 8.5.0 vs perl 5.8.8

C:\opt\tcl\src\tcl\win>tclsh85t powbench.tcl
0.3611 microseconds per iteration

C:\opt\tcl\src\tcl\win>perl powbench.pl
Time is  4 wallclock secs ( 2.98 usr  0.08 sys +  0.00 cusr  0.00 csys =  3.06 CPU)seconds