Posted to tcl by dkf at Mon Sep 20 22:27:15 GMT 2010view raw

  1. C:\Documents and Settings\Donal>tclsh85
  2. % info patch
  3. 8.5.2
  4. % package require ActiveTcl
  5. 8.5.2.0.284846
  6. % eval {set str1 [string repeat "*" 10000]
  7. set str2 ${str1}b
  8. append str1 a ;string length $str1}
  9. 10001
  10. % time {string equal $str1 $str2} 10000
  11. 16.0505 microseconds per iteration
  12. % time {string compare $str1 $str2} 10000
  13. 10.9383 microseconds per iteration
  14. % time {string equal $str1 $str2} 100000
  15. 15.98994 microseconds per iteration
  16. % time {string compare $str1 $str2} 100000
  17. 11.02129 microseconds per iteration
  18. % eval {set str1 [string repeat "*" 100000]
  19. set str2 ${str1}b
  20. append str1 a ;string length $str1}
  21. 100001
  22. % time {string equal $str1 $str2} 10000
  23. 181.5137 microseconds per iteration
  24. % time {string compare $str1 $str2} 10000
  25. 115.1879 microseconds per iteration
  26.