Posted to tcl by mjanssen at Mon Oct 22 19:23:53 GMT 2007view raw

  1. # static non-threaded build: ./configure --disable-shared --disable-threads --disable-symbols CFLAGS="-march=i686"
  2. mjanssen@juno:~/test$ tclsh8.5 test.tcl test.dat > /dev/null
  3. 15882535
  4. 16545939
  5. 15709562
  6. 15764823
  7. 16055450
  8. 16917391
  9. 15800930
  10. 16009375
  11. 16300071
  12. 16056347
  13. mean: 16104242.3
  14. sdev: 383037.6532669109
  15.  
  16. # shared, threaded build: ./configure
  17. mjanssen@juno:~/test$ tclsh8.5 test.tcl test.dat > /dev/null
  18. 50255500
  19. 48259472
  20. 46758870
  21. 44438737
  22. 45814076
  23. 45172940
  24. 44581582
  25. 46459528
  26. 44839097
  27. 44579642
  28. mean: 46115944.4
  29. sdev: 1897374.5886940137
  30.  
  31. # script
  32. fconfigure stdout -buffering full
  33.  
  34. proc my_grep {re file} {
  35. set f [open $file r]
  36. fconfigure $f -encoding ascii -translation lf
  37. while {[gets $f buf] >= 0} {
  38. if {[regexp -- $re $buf]} {puts $buf}
  39. }
  40. close $f
  41. }
  42. set re {^$}
  43. fconfigure stdout -encoding binary -translation binary
  44. foreach file $argv {
  45. foreach i {0 1 2 3 4 5 6 7 8 9} {
  46. lappend res [lindex [time {my_grep $re $file} 1] 0]
  47. puts stderr [lindex $res end]
  48. }
  49. }
  50. puts stderr "mean: [::math::statistics::mean $res]"
  51. puts stderr "sdev: [::math::statistics::stdev $res]"
  52.