[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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 483: 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
[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
[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
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4586: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4588: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4589: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4590: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
AI Challenge Forums • View topic - Getting accurate time in C (to avoid timeout)

It is currently Sat Jul 21, 2018 9:36 pm Advanced search

Getting accurate time in C (to avoid timeout)

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

Getting accurate time in C (to avoid timeout)

Postby liberforce » Sat Nov 12, 2011 5:47 am

liberforce
Cadet
 
Posts: 7
Joined: Sat Nov 12, 2011 5:32 am

Re: Getting accurate time in C (to avoid timeout)

Postby tmc » Sat Nov 12, 2011 7:10 am

You must measure real time, not the CPU time of your thread or process. Also make sure that you're not doing anything after writing the "ready" line, or you'll eat into the time for your next turn without being able to measure how much time you've spent.
tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: Getting accurate time in C (to avoid timeout)

Postby liberforce » Sat Nov 12, 2011 8:06 pm

I've tried with gettimeofday and I still have the same problem... I'm ok with getting the wall clock time, but which function am I supposed to use ?
liberforce
Cadet
 
Posts: 7
Joined: Sat Nov 12, 2011 5:32 am

Re: Getting accurate time in C (to avoid timeout)

Postby Janzert » Sun Nov 13, 2011 1:19 am

Besides making sure you're using wall clock time, one other thing is make sure you are flushing stdout after writing out your turn.
Janzert
Contest Organizer
 
Posts: 271
Joined: Sun Feb 07, 2010 1:59 am

Re: Getting accurate time in C (to avoid timeout)

Postby kuisma » Sun Nov 13, 2011 10:01 am

kuisma
Captain
 
Posts: 22
Joined: Mon Oct 31, 2011 8:46 am

Re: Getting accurate time in C (to avoid timeout)

Postby liberforce » Sun Nov 13, 2011 5:49 pm

liberforce
Cadet
 
Posts: 7
Joined: Sat Nov 12, 2011 5:32 am

Re: Getting accurate time in C (to avoid timeout)

Postby liberforce » Sun Nov 13, 2011 11:13 pm

Ok, I tried some more things:
calling usleep and timing, I clearly get timeouts when the sleep duration is > turntime. For example, calling usleep (100000) for a 100ms turntime even works a few times until it times out. However, when doing some real processing, I may get a timeout after 5.2ms with a turntime of 100ms !

My hardware is a netbook with a N570 Intel Atom processor (64 bits, two cores). I'm runninng a 64-bits Linux (Mageia 1) with kernel 2.6.38.

So I think either wall clock time is not the right way of measuring, or playgame.py is buggy, or I'm dumb and did an obvious mistake I can't see because I've been working for 14+ hours on this the last two days...

Hints anyone ?
liberforce
Cadet
 
Posts: 7
Joined: Sat Nov 12, 2011 5:32 am

Re: Getting accurate time in C (to avoid timeout)

Postby TwistedLogic » Mon Nov 14, 2011 6:11 am

You said that you're using "--serial", I am not sure but if based on what you've described about it that the sum of all the other bots time including yours should only be within the turn time or it would time out. Ca you try not using "--serial"?
TwistedLogic
Lieutenant
 
Posts: 14
Joined: Fri Oct 28, 2011 4:48 pm

Re: Getting accurate time in C (to avoid timeout)

Postby tmc » Mon Nov 14, 2011 7:10 am

tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: Getting accurate time in C (to avoid timeout)

Postby liberforce » Mon Nov 14, 2011 10:18 am

liberforce
Cadet
 
Posts: 7
Joined: Sat Nov 12, 2011 5:32 am

Next

Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron