Posted to tcl by mcvoy at Fri Oct 26 15:57:54 GMT 2007view raw

  1. Profiling results for cat.tcl (see below, it does the read path but skips write) on a million lines of data.
  2.  
  3. Each sample counts as 0.01 seconds.
  4. % cumulative self self total
  5. time seconds seconds calls s/call s/call name
  6. 17.59 0.54 0.54 24 0.02 0.02 TclExecuteByteCode
  7. 8.79 0.81 0.27 1000001 0.00 0.00 Tcl_GetsObj
  8. 7.82 1.05 0.24 main
  9. 6.51 1.25 0.20 3001186 0.00 0.00 Tcl_CreateHashEntry
  10. 3.58 1.36 0.11 3000488 0.00 0.00 CompareStringKeys
  11. 3.58 1.47 0.11 1000170 0.00 0.00 TclLookupSimpleVar
  12. 3.26 1.57 0.10 2041601 0.00 0.00 Tcl_ExternalToUtf
  13. 2.93 1.66 0.09 3001057 0.00 0.00 HashStringKey
  14. 2.93 1.75 0.09 2041942 0.00 0.00 BinaryProc
  15. 2.93 1.84 0.09 1000454 0.00 0.00 TclFreeObj
  16. 2.93 1.93 0.09 1000117 0.00 0.00 TclPtrSetVar
  17. 2.93 2.02 0.09 1000098 0.00 0.00 TclEvalObjvInternal
  18. 2.93 2.11 0.09 1000001 0.00 0.00 Tcl_GetsObjCmd
  19. 2.61 2.19 0.08 1041589 0.00 0.00 FilterInputBytes
  20. 1.95 2.25 0.06 2041678 0.00 0.00 Tcl_SetObjLength
  21. 1.95 2.31 0.06 2000159 0.00 0.00 Tcl_GetCommandFromObj
  22. 1.95 2.37 0.06 1000010 0.00 0.00 Tcl_GetAssocData
  23. 1.63 2.42 0.05 2041882 0.00 0.00 SetStringFromAny
  24. 1.63 2.47 0.05 1000007 0.00 0.00 Tcl_ObjSetVar2
  25. 1.30 2.51 0.04 2003006 0.00 0.00 Tcl_Alloc
  26. 1.30 2.55 0.04 1000214 0.00 0.00 Tcl_SetObjResult
  27. 1.30 2.59 0.04 1000120 0.00 0.00 TclpCheckStackSpace
  28. 1.30 2.63 0.04 1000092 0.00 0.00 Tcl_NewObj
  29. 1.30 2.67 0.04 1000010 0.00 0.00 Tcl_NewIntObj
  30. 0.98 2.70 0.03 3000543 0.00 0.00 Tcl_GetThreadData
  31. 0.98 2.73 0.03 2003114 0.00 0.00 TclpAlloc
  32. 0.98 2.76 0.03 2000881 0.00 0.00 Tcl_GetStringFromObj
  33. 0.98 2.79 0.03 1000007 0.00 0.00 CheckChannelErrors
  34. 0.98 2.82 0.03 1000001 0.00 0.00 CommonGetsCleanup
  35. 0.65 2.84 0.02 2001914 0.00 0.00 TclpFree
  36. 0.65 2.86 0.02 2000757 0.00 0.00 Tcl_FindHashEntry
  37. 0.65 2.88 0.02 1000211 0.00 0.00 TclCleanupCommand
  38. 0.65 2.90 0.02 1000123 0.00 0.00 Tcl_LimitExceeded
  39. 0.65 2.92 0.02 1000121 0.00 0.00 Tcl_LimitReady
  40. 0.65 2.94 0.02 1000120 0.00 0.00 TclInterpReady
  41. 0.65 2.96 0.02 1000053 0.00 0.00 FreeStringInternalRep
  42. 0.65 2.98 0.02 1000052 0.00 0.00 TclObjLookupVar
  43. 0.65 3.00 0.02 1000011 0.00 0.00 Tcl_DeleteFileHandler
  44. 0.65 3.02 0.02 1000002 0.00 0.00 Tcl_GetChannel
  45. 0.33 3.03 0.01 3000300 0.00 0.00 Tcl_GetString
  46. 0.33 3.04 0.01 1000234 0.00 0.00 ResetObjResult
  47. 0.33 3.05 0.01 1000233 0.00 0.00 Tcl_ResetResult
  48. 0.33 3.06 0.01 1000214 0.00 0.00 Tcl_GetObjResult
  49. 0.33 3.07 0.01 1000004 0.00 0.00 FileWatchProc
  50. 0.00 3.07 0.00 2001914 0.00 0.00 Tcl_Free
  51. 0.00 3.07 0.00 1000121 0.00 0.00 Tcl_AsyncReady
  52.  
  53.  
  54. proc cat {file} {
  55. set f [open $file]
  56. # Good for 11% perf win
  57. # set buf ""
  58. while {[gets $f buf] >= 0} {
  59. }
  60. close $f
  61. }
  62.  
  63. foreach file $argv {
  64. cat $file
  65. }
  66.  
  67.