[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
AI Challenge Forums • View topic - profiling python 2.7 bot

It is currently Sun Jun 24, 2018 2:57 am Advanced search

profiling python 2.7 bot

Topics about starter packages, visualizer or any other third party tools.
Please submit new language requests in the Language Request Forum.

profiling python 2.7 bot

Postby erdman » Wed Dec 07, 2011 2:30 am

anyone figure out how to do this?

i've tried cProfile, based on instructions here: http://docs.python.org/library/profile.html
tried editing the calling function from command-line startup, also tried inserting the profiling call into 'main' of the MyBot.py.

also tried valgrind based on this post: viewtopic.php?f=24&t=1746&p=12001&hilit=profiling#p12001

there is no output from cProfile, and valgrind causes my bot to timeout on first turn.

anyone have any luck with this?
erdman
Major
 
Posts: 34
Joined: Thu Oct 27, 2011 12:52 am

Re: profiling python 2.7 bot

Postby erdman » Wed Dec 07, 2011 3:01 am

specifically, i've tried cProfile calls like this:

python tcpclient.py tcpants.com 2081 "python -m cProfile -o botprof.log MyBot.py" username password
python playgame.py "python -m cProfile -o botprof.log MyBot.py" "python GreedyBot.py" ...

in the 'if __name__ == '__main__': section of MyBot.py:
I changed
Ants.run(MyBot())

to
cProfile('Ants.run(MyBot())','botprof.log')

None of those provided any output.


Based on this :
http://wiki.python.org/moin/PythonSpeed/Profiling

I also tried:
python tcpclient.py tcpants.com 2081 "python lsprofcalltree.py -o botprof.log MyBot.py" username password

Still no output produced. Any help or ideas are welcome.
erdman
Major
 
Posts: 34
Joined: Thu Oct 27, 2011 12:52 am

Re: profiling python 2.7 bot

Postby franperuzzi » Wed Dec 07, 2011 12:02 pm

My situation is even stranger. I have had output from "python -m cProfile -o out.prof MyBot.py", but only sporadically. For instance I was trying it last night, and it didn't work a few times, then it produced the output file once, then I couldn't get to work again. I feel like I'm banging my head against a wall.
franperuzzi
Captain
 
Posts: 20
Joined: Sat Feb 20, 2010 4:40 am

Re: profiling python 2.7 bot

Postby ksq » Thu Dec 08, 2011 10:24 pm

Same situation!! Profiling for MyBot is not working either through command line or by coding for it in main of MyBot. I even tried changing the command in engine.py but no result either..
for b, bot in enumerate(botcmds):
bot_cwd, bot_cmd = bot
if bot_cmd == 'python .\MyBot.py':
bot_cmd = 'python -m cProfile -o "C:\\mybot1" .\MyBot.py'

Any inputs from game organizers ??
ksq
Cadet
 
Posts: 2
Joined: Wed Oct 26, 2011 5:52 am

Re: profiling python 2.7 bot

Postby BenJackson » Thu Dec 08, 2011 10:58 pm

Does python take a long time to write the profiling and exit at the end? The game engine may be killing it off. Try increasing --end_time
BenJackson
Colonel
 
Posts: 94
Joined: Sat Oct 29, 2011 4:16 am

Re: profiling python 2.7 bot

Postby franperuzzi » Fri Dec 09, 2011 12:26 am

franperuzzi
Captain
 
Posts: 20
Joined: Sat Feb 20, 2010 4:40 am

Re: profiling python 2.7 bot

Postby McLeopold » Fri Dec 09, 2011 1:01 am

McLeopold
Contest Organizer
 
Posts: 262
Joined: Sun Sep 19, 2010 3:31 am

Re: profiling python 2.7 bot

Postby franperuzzi » Fri Dec 09, 2011 4:23 am

That appears to work great. I tried it before, when GarySWest suggested it, but for some reason I didn't like it at the time. Now I have no idea why, since it looks like it is a great solution to my profiling problems.
franperuzzi
Captain
 
Posts: 20
Joined: Sat Feb 20, 2010 4:40 am


Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 2 guests

cron