profile.run won't run!
Nick Perkins
nperkins7 at home.com
Fri Jun 15 01:25:12 EDT 2001
More information about the Python-list mailing list
Fri Jun 15 01:25:12 EDT 2001
- Previous message (by thread): Regexp-problem
- Next message (by thread): profile.run won't run!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Rainer Deyke" <root at rainerdeyke.com> wrote in message news:24gW6.284794$oc7.18522490 at news2.rdc2.tx.home.com... > ... > import __main__ > __main__.solve_problem = solve_problem > profile.run('solve_problem') Thanks, the profiler actually runs, now! but... The broblem is that it seems not to actually execute the function... ..here is a simpler script that shows what i mean... --BEGIN SCRIPT import time, profile def solve_problem(): start = time.time() print 'SOLVING PROBLEM...' x=0 for i in range(10**3): for j in range(10**3): x = i + j print x print 'DONE in %.2f seconds'%(time.time()-start) from pprint import pprint as pp print 'globals:' pp (globals()) print print 'locals:' pp (locals()) print 'direct:' solve_problem() import __main__ __main__.solve_problem = solve_problem print 'profiled:' profile.run('solve_problem') --END SCRIPT ..which produces .. --BEGIN OUTPUT globals: {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__name__': '__main__', 'pp': <function pprint at 00EBD61C>, 'profile': <module 'profile' from 'c:\python21\lib\profile.pyc'>, 'pywin': <module 'pywin' from 'c:\python21\pythonwin\pywin\__init__.pyc'>, 'solve_problem': <function solve_problem at 00EBB97C>, 'time': <module 'time' (built-in)>} locals: {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__name__': '__main__', 'pp': <function pprint at 00EBD61C>, 'profile': <module 'profile' from 'c:\python21\lib\profile.pyc'>, 'pywin': <module 'pywin' from 'c:\python21\pythonwin\pywin\__init__.pyc'>, 'solve_problem': <function solve_problem at 00EBB97C>, 'time': <module 'time' (built-in)>} direct: SOLVING PROBLEM... 1998 DONE in 1.75 seconds profiled: 2 function calls in 0.029 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 <string>:1(?) 0 0.000 0.000 profile:0(profiler) 1 0.029 0.029 0.029 0.029 profile:0(solve_problem) .. the profile.run(..) seems to have not actually called the function. There is no output (which might be re-directed, i suppose), but more importantly, not enough time elapsed for the fn to have been called. .. i am stumped. what is going on?
- Previous message (by thread): Regexp-problem
- Next message (by thread): profile.run won't run!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list