Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [77]: cProfile.run('print(sum(file_block_count_lf(open(fn))))')
- 15496800
- 10977 function calls in 6.479 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1588 0.034 0.000 6.472 0.004 <ipython-input-76-8d8b0ada3387>:1(file_block_count_lf)
- 1 0.000 0.000 6.479 6.479 <string>:1(<module>)
- 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
- 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
- 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
- 2068 0.037 0.000 1.993 0.001 codecs.py:310(decode)
- 2068 0.004 0.000 0.004 0.000 codecs.py:322(getstate)
- 1 0.000 0.000 6.479 6.479 {built-in method exec}
- 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
- 1 0.000 0.000 0.000 0.000 {built-in method open}
- 1 0.000 0.000 0.000 0.000 {built-in method print}
- 1 0.006 0.006 6.478 6.478 {built-in method sum}
- 2068 1.956 0.001 1.956 0.001 {built-in method utf_8_decode}
- 1587 1.927 0.001 1.927 0.001 {method 'count' of 'str' objects}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- 1588 2.514 0.002 4.511 0.003 {method 'read' of '_io.TextIOWrapper' objects}
- In [78]: def file_block_count_lf(f) :
- while True :
- k = f.read(1<<20)
- if k == '' :
- break
- yield k.count('\n')
- In [79]: cProfile.run('for i,v in enumerate(open(fn)): pass\nprint(i)')
- 15496799
- 406215 function calls in 10.868 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 9.675 9.675 10.868 10.868 <string>:1(<module>)
- 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
- 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
- 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
- 203103 0.485 0.000 1.191 0.000 codecs.py:310(decode)
- 1 0.000 0.000 10.868 10.868 {built-in method exec}
- 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
- 1 0.001 0.001 0.001 0.001 {built-in method open}
- 1 0.000 0.000 0.000 0.000 {built-in method print}
- 203103 0.706 0.000 0.706 0.000 {built-in method utf_8_decode}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- In [78]: cProfile.run('print(sum(1 for l in open(fn)))')
- 15496800
- 15903017 function calls in 14.557 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 15496801 9.634 0.000 10.825 0.000 <string>:1(<genexpr>)
- 1 0.000 0.000 14.557 14.557 <string>:1(<module>)
- 1 0.000 0.000 0.000 0.000 _bootlocale.py:23(getpreferredencoding)
- 1 0.000 0.000 0.000 0.000 codecs.py:251(__init__)
- 1 0.000 0.000 0.000 0.000 codecs.py:300(__init__)
- 203103 0.481 0.000 1.191 0.000 codecs.py:310(decode)
- 1 0.000 0.000 14.557 14.557 {built-in method exec}
- 1 0.000 0.000 0.000 0.000 {built-in method nl_langinfo}
- 1 0.001 0.001 0.001 0.001 {built-in method open}
- 1 0.000 0.000 0.000 0.000 {built-in method print}
- 1 3.731 3.731 14.555 14.555 {built-in method sum}
- 203103 0.710 0.000 0.710 0.000 {built-in method utf_8_decode}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- $ cat /proc/cpuinfo
- processor : 0
- vendor_id : GenuineIntel
- cpu family : 6
- model : 15
- model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
- stepping : 13
- microcode : 0xa4
- cpu MHz : 1200.000
- cache size : 1024 KB
- physical id : 0
- siblings : 2
- core id : 0
- cpu cores : 2
- apicid : 0
- initial apicid : 0
- fpu : yes
- fpu_exception : yes
- cpuid level : 10
- wp : yes
- 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
- bugs :
- bogomips : 3991.40
- clflush size : 64
- cache_alignment : 64
- address sizes : 36 bits physical, 48 bits virtual
- power management:
- processor : 1
- vendor_id : GenuineIntel
- cpu family : 6
- model : 15
- model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
- stepping : 13
- microcode : 0xa4
- cpu MHz : 2000.000
- cache size : 1024 KB
- physical id : 0
- siblings : 2
- core id : 1
- cpu cores : 2
- apicid : 1
- initial apicid : 1
- fpu : yes
- fpu_exception : yes
- cpuid level : 10
- wp : yes
- 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
- bugs :
- bogomips : 3991.40
- clflush size : 64
- cache_alignment : 64
- address sizes : 36 bits physical, 48 bits virtual
- power management:
- $ ls -l more_logs.txt
- -rw-r--r-- 1 chris users 1663809100 Jan 18 21:18 more_logs.txt
- $ python -V
- Python 3.4.2
Advertisement
Add Comment
Please, Sign In to add comment