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

  1. # tcl version
  2. package require Tcl 8.5
  3. puts [time {expr {101**1002}} 100000]
  4.  
  5. #---------------------------------------------
  6. #perl version
  7. use bigint;
  8. use Benchmark;
  9.  
  10. my $start = new Benchmark;
  11. my $r = 0;
  12. for (my $n = 0; $n < 100000; $n++) {
  13. #$r = Math::BigInt::bpow(101,1002);
  14. $r = 101 ** 1002;
  15. }
  16.  
  17. my $end = new Benchmark;
  18. my $diff = timediff($end, $start);
  19. print "Time is ", timestr($diff, 'all'), "seconds";
  20.  
  21. #---------------------------------------------
  22. # tcl 8.5.0 vs perl 5.8.8
  23.  
  24. C:\opt\tcl\src\tcl\win>tclsh85t powbench.tcl
  25. 0.3611 microseconds per iteration
  26.  
  27. C:\opt\tcl\src\tcl\win>perl powbench.pl
  28. Time is 4 wallclock secs ( 2.98 usr 0.08 sys + 0.00 cusr 0.00 csys = 3.06 CPU)seconds