cpuConstant

Jump to navigation Jump to search

cpuConstant

Hi all, I decided to work on my skipped turns and to watch my execution time. As the first step, I recalculated cpuConstant according to cpuManager code (I wish it would be available from within the robot) at the beginning of each round. Guess what. The number wildly fluctuate. By wildly, we are talkin more than FOUR times!!! On the short end of the spectrum cpuConstant is about 8mS and it can be as large as 35mS.

Any ideas what is going on? Everything is done with openjdk8. One difference from the original code: I measure time with System.nanoTime()

Beaming (talk)04:37, 17 October 2017

Yes with Turbo Boost, CPU speed is not constant ;) And I think every new CPU should have something like that.

Xor (talk)04:40, 17 October 2017

I would expect the cpuConstant go lower as turbo kicks in. But my first run usually gives lower number (faster speed), and consequent executions typically but not always are longer/slower.

In either case it is a problem. Recall recently discussed ThreadDeath issue.

Beaming (talk)04:46, 17 October 2017

Do you relay highly on GC? I mean do you create objects in loops? If the speed gets slower, I can only guess that would be GC.

Xor (talk)05:05, 17 October 2017

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:User talk:Beaming/cpuConstant/reply (4).

Kd-trees and HashMaps is fast and GC friendly IMO. Did u tried recalculate CPU constant?

Xor (talk)05:47, 17 October 2017
 

You mean the robocode properties file says CPU constant = 6ms?

Xor (talk)05:47, 17 October 2017

I did a bit of rounding but yes. Also, this is the number which I get if ask GUI to recalculate cpuConstant.

Beaming (talk)16:03, 17 October 2017
 

Robocode gives robots extra time at the beginning of a round. In addition, most of this time is probably taken away by one-time setup and initialization code, making your calculated CPU constant longer than it should be.

MultiplyByZer0 (talk)22:03, 17 October 2017

Ok. I see why skipped turn event is not fired. But the wildly fluctuating cpu constants is still under the question. The cpu constant calculation is done within one call: it just long loop with heavy math.

Unless GC kicks in at random I see no explanation for it. The problem that it probably does it during the round as well, since I see wildly fluctuating timing in my profiler.

Beaming (talk)22:38, 17 October 2017