cprofile

PyPy significantly slower than CPython

孤街醉人 提交于 2019-12-21 03:58:16
问题 I've been testing a cacheing system of my making. Its purpose is to speed up a Django web application. It stores everything in-memory. According to cProfile most of the time in my tests is spent inside QuerySet._clone() which turns out to be terribly inefficient (it's actually not that strange given the implementation). I was having high hopes for using PyPy to speed things up. I've got a 64-bit machine. However after installing all the required libraries it turns out that PyPy compiled code

cProfile taking a lot of memory

爷,独闯天下 提交于 2019-12-13 19:54:02
问题 I am attempting to profile my project in python, but I am running out of memory. My project itself is fairly memory intensive, but even half-size runs are dieing with "MemoryError" when run under cProfile. Doing smaller runs is not a good option, because we suspect that the run time is scaling super-linearly, and we are trying to discover which functions are dominating during large runs. Why is cProfile taking so much memory? Can I make it take less? Is this normal? 回答1: Updated : Since

Profile Python cProfile vs unix time

大兔子大兔子 提交于 2019-12-12 01:25:22
问题 I am profiling a python code ; why does it spend more time in the user space ? user@terminal$ time python main.py 1964 function calls in 0.003 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.003 0.003 :1() 1 0.000 0.000 0.000 0.000 ConfigParser.py:218( init ) 1 0.000 0.000 0.001 0.001 ConfigParser.py:266(read) 30 0.000 0.000 0.000 0.000 ConfigParser.py:354(optionxform) 1 0.000 0.000 0.000 0.000 ConfigParser.py:434(_read)

Are python generators faster than nested for loops? [closed]

≡放荡痞女 提交于 2019-12-11 15:39:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 months ago . I having some problems trying to understand generators. Do these function's execution time differ when doing the same task? def slow_sum(size): x= 0 for i in range(size): for j in range(size): x += i + j return x def fast_sum(size): return sum( [ (i+j) for j in range(size) for i in range(size)] ) size = 2000

profiling numpy with cProfile not giving useful results

匆匆过客 提交于 2019-12-10 16:20:00
问题 This code: import numpy as np import cProfile shp = (1000,1000) a = np.ones(shp) o = np.zeros(shp) def main(): np.divide(a,1,o) for i in xrange(20): np.multiply(a,2,o) np.add(a,1,o) cProfile.run('main()') prints only: 3 function calls in 0.269 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.269 0.269 <string>:1(<module>) 1 0.269 0.269 0.269 0.269 testprof.py:8(main) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Prof

Cannot import cProfile in Python 3

我怕爱的太早我们不能终老 提交于 2019-12-08 14:58:50
问题 I am trying to import the cProfile module into Python 3.3.0, but I got the following error: Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> import cProfile File "/.../cProfile_try.py", line 12, in <module> help(cProfile.run) AttributeError: 'module' object has no attribute 'run' The complete code ( cProfile_try.py ) is as follows import cProfile help(cProfile.run) L = list(range(10000000)) len(L) # 10000000 def binary_search(L, v): """ (list, object) -> int

Increasing the depth of cProfiler in Python to report more functions?

只谈情不闲聊 提交于 2019-12-06 21:21:32
问题 I'm trying to profile a function that calls other functions. I call the profiler as follows: from mymodule import foo def start(): # ... foo() import cProfile as profile profile.run('start()', output_file) p = pstats.Stats(output_file) print "name: " print p.sort_stats('name') print "all stats: " p.print_stats() print "cumulative (top 10): " p.sort_stats('cumulative').print_stats(10) I find that the profiler says all the time was spend in function "foo()" of mymodule, instead of brekaing it

cProfile adds significant overhead when calling numba jit functions

偶尔善良 提交于 2019-12-05 13:51:48
问题 Compare a pure Python no-op function with a no-op function decorated with @numba.jit , that is: import numba @numba.njit def boring_numba(): pass def call_numba(x): for t in range(x): boring_numba() def boring_normal(): pass def call_normal(x): for t in range(x): boring_normal() If we time this with %timeit , we get the following: %timeit call_numba(int(1e7)) 792 ms ± 5.51 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) %timeit call_normal(int(1e7)) 737 ms ± 2.7 ms per loop (mean ± std.

Increasing the depth of cProfiler in Python to report more functions?

微笑、不失礼 提交于 2019-12-05 02:28:38
I'm trying to profile a function that calls other functions. I call the profiler as follows: from mymodule import foo def start(): # ... foo() import cProfile as profile profile.run('start()', output_file) p = pstats.Stats(output_file) print "name: " print p.sort_stats('name') print "all stats: " p.print_stats() print "cumulative (top 10): " p.sort_stats('cumulative').print_stats(10) I find that the profiler says all the time was spend in function "foo()" of mymodule, instead of brekaing it down into the subfunctions foo() calls, which is what I want to see. How can I make the profiler report

Profile a python script using cProfile into an external file

。_饼干妹妹 提交于 2019-12-05 00:14:53
I am new to python programming.I have a python script and I am trying to profile it using cProfile command. I typed the following python -m cProfile -o readings.txt my_script.py It generated readings.txt . But when I try to open the file using any standard text editor or notepad, the file doesn't open properly. It doesn't contain the data Can anyone please tell me how to store these statistics into an external file that can be opened using notepad?? I am using windows platform The output file generated by the cProfile -o module isn't plaintext ; it's a serialized pstats.Stats object. Rather