Guest User

Untitled

a guest
Jan 18th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. In [77]: cProfile.run('print(sum(file_block_count_lf(open(fn))))')
  2. 15496800
  3. 10977 function calls in 6.479 seconds
  4.  
  5. Ordered by: standard name
  6.  
  7. ncalls tottime percall cumtime percall filename:lineno(function)
  8. 1588 0.034 0.000 6.472 0.004 <ipython-input-76-8d8b0ada3387>:1(file_block_count_lf)
  9. 1 0.000 0.000 6.479 6.479 <string>:1(<module>)
  10. 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
  11. 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
  12. 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
  13. 2068 0.037 0.000 1.993 0.001 codecs.py:310(decode)
  14. 2068 0.004 0.000 0.004 0.000 codecs.py:322(getstate)
  15. 1 0.000 0.000 6.479 6.479 {built-in method exec}
  16. 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
  17. 1 0.000 0.000 0.000 0.000 {built-in method open}
  18. 1 0.000 0.000 0.000 0.000 {built-in method print}
  19. 1 0.006 0.006 6.478 6.478 {built-in method sum}
  20. 2068 1.956 0.001 1.956 0.001 {built-in method utf_8_decode}
  21. 1587 1.927 0.001 1.927 0.001 {method 'count' of 'str' objects}
  22. 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
  23. 1588 2.514 0.002 4.511 0.003 {method 'read' of '_io.TextIOWrapper' objects}
  24.  
  25. In [78]: def file_block_count_lf(f) :
  26. while True :
  27. k = f.read(1<<20)
  28. if k == '' :
  29. break
  30. yield k.count('\n')
  31.  
  32. In [79]: cProfile.run('for i,v in enumerate(open(fn)): pass\nprint(i)')
  33. 15496799
  34. 406215 function calls in 10.868 seconds
  35.  
  36. Ordered by: standard name
  37.  
  38. ncalls tottime percall cumtime percall filename:lineno(function)
  39. 1 9.675 9.675 10.868 10.868 <string>:1(<module>)
  40. 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
  41. 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
  42. 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
  43. 203103 0.485 0.000 1.191 0.000 codecs.py:310(decode)
  44. 1 0.000 0.000 10.868 10.868 {built-in method exec}
  45. 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
  46. 1 0.001 0.001 0.001 0.001 {built-in method open}
  47. 1 0.000 0.000 0.000 0.000 {built-in method print}
  48. 203103 0.706 0.000 0.706 0.000 {built-in method utf_8_decode}
  49. 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
  50.  
  51. In [78]: cProfile.run('print(sum(1 for l in open(fn)))')
  52. 15496800
  53. 15903017 function calls in 14.557 seconds
  54.  
  55. Ordered by: standard name
  56.  
  57. ncalls tottime percall cumtime percall filename:lineno(function)
  58. 15496801 9.634 0.000 10.825 0.000 <string>:1(<genexpr>)
  59. 1 0.000 0.000 14.557 14.557 <string>:1(<module>)
  60. 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
  61. 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
  62. 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
  63. 203103 0.481 0.000 1.191 0.000 codecs.py:310(decode)
  64. 1 0.000 0.000 14.557 14.557 {built-in method exec}
  65. 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
  66. 1 0.001 0.001 0.001 0.001 {built-in method open}
  67. 1 0.000 0.000 0.000 0.000 {built-in method print}
  68. 1 3.731 3.731 14.555 14.555 {built-in method sum}
  69. 203103 0.710 0.000 0.710 0.000 {built-in method utf_8_decode}
  70. 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
  71.  
  72. $ cat /proc/cpuinfo
  73. processor : 0
  74. vendor_id : GenuineIntel
  75. cpu family : 6
  76. model : 15
  77. model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
  78. stepping : 13
  79. microcode : 0xa4
  80. cpu MHz : 1200.000
  81. cache size : 1024 KB
  82. physical id : 0
  83. siblings : 2
  84. core id : 0
  85. cpu cores : 2
  86. apicid : 0
  87. initial apicid : 0
  88. fpu : yes
  89. fpu_exception : yes
  90. cpuid level : 10
  91. wp : yes
  92. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm
  93. bugs :
  94. bogomips : 3991.40
  95. clflush size : 64
  96. cache_alignment : 64
  97. address sizes : 36 bits physical, 48 bits virtual
  98. power management:
  99.  
  100. processor : 1
  101. vendor_id : GenuineIntel
  102. cpu family : 6
  103. model : 15
  104. model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
  105. stepping : 13
  106. microcode : 0xa4
  107. cpu MHz : 2000.000
  108. cache size : 1024 KB
  109. physical id : 0
  110. siblings : 2
  111. core id : 1
  112. cpu cores : 2
  113. apicid : 1
  114. initial apicid : 1
  115. fpu : yes
  116. fpu_exception : yes
  117. cpuid level : 10
  118. wp : yes
  119. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm
  120. bugs :
  121. bogomips : 3991.40
  122. clflush size : 64
  123. cache_alignment : 64
  124. address sizes : 36 bits physical, 48 bits virtual
  125. power management:
  126.  
  127. $ ls -l more_logs.txt
  128. -rw-r--r-- 1 chris users 1663809100 Jan 18 21:18 more_logs.txt
  129.  
  130. $ python -V
  131. Python 3.4.2
Advertisement
Add Comment
Please, Sign In to add comment