I'm going to enter MIT's battlecode competition. The entrants write programs that control robots that fight each other. The catch is that your robots are limited to executing a certain amount of bytecode in a turn (last year it was 10000 per turn). Now, a simple loop like
(int i=0; i<100; i++){
// do nothing
}
uses, according to their software, approximately 400 bytecode (presumably something like (2 bytecode for incrementing i plus 2 bytecode for checking if i<100) * 100 = 400 bytecode) so we have to write very tight code. Hence, as I try out some different navigation algorithms its important that I be able to figure out how much bytecode my code is using -- how can I do this?
(It IS possible -- they do it, I'm just not sure how! Also, they must stop the JIT from coming into play somehow. I know that each robot is run in a separate Thread, so I'm sure the answer involves some sort of Thread trickery I don't know about.)
You can get the count by using a debug build of the Hotspot JVM (which can be found here) and running it with the -XX:+CountBytecodes
flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With