Page 1 of 2

NBC speed

Posted: 17 May 2011, 02:51
by mattallen37
How fast does NBC code execute? Is it a fixed speed per line?

Re: NBC speed

Posted: 17 May 2011, 04:36
by muntoo
Depends on the operation.

It's a few thousand integer math operations per second, IIRC.

Linus did some great work, but it's lost with NXTasy.

(The topic was called "NXC performance insights", I believe.)

Re: NBC speed

Posted: 17 May 2011, 04:54
by mattallen37
Hmm, I was hoping for specifics.

Re: NBC speed

Posted: 17 May 2011, 11:53
by linusa
Even though the fruitful discussion with John Hansen and others is lost, my benchmark programs are still there. The comments section at the top contains most of my original article from NXTasy:

http://www.mindstorms.rwth-aachen.de/tr ... ceChk1.nxc
http://www.mindstorms.rwth-aachen.de/tr ... ceChk2.nxc
http://www.mindstorms.rwth-aachen.de/tr ... ceChk3.nxc
http://www.mindstorms.rwth-aachen.de/tr ... ceChk4.nxc

Please note that the Firmware 1.2x seems to be about two times faster than the old 1.0x generation.

Please also note that this doesn't say anything about sensor or motor access, and that you always have to be careful when benchmarking and comparing results.

Re: NBC speed

Posted: 17 May 2011, 13:04
by linusa
Oh and I remember one important thing that changed with Firmware 1.2x (or newer NXC versions), which is not yet mentioned in the comments of my Benchmarks: The Wait-command in NXC has changed from "busy waiting that burns CPU time" to a "real sleep, let other tasks use CPU".

Re: NBC speed

Posted: 17 May 2011, 17:24
by afanofosc
Definitely not a fixed speed per line of code. Some opcodes take longer to execute than others. Some opcodes with one datatype for its parameters take longer than the same opcode with a different datatype. E.g., mov with byte array inputs will take longer than mov with signed long inputs. It is always best to reveal the hidden motivation behind the question, imho. Why did you hope for specifics about how fast NBC code executes on the NXT firmware?

John Hansen

Re: NBC speed

Posted: 17 May 2011, 18:06
by mattallen37
Thank you very much Linus.

Re: NBC speed

Posted: 17 May 2011, 18:17
by mattallen37
Okay, thanks John. I don't know all that much about how CPUs compute, but I though that if it was a fixed speed, I could do timing based on the number of OPCodes. I though maybe I could get higher resolution that CurrentTick gives.

Re: NBC speed

Posted: 17 May 2011, 21:30
by ronmcrae
linusa wrote:Oh and I remember one important thing that changed with Firmware 1.2x (or newer NXC versions), which is not yet mentioned in the comments of my Benchmarks: The Wait-command in NXC has changed from "busy waiting that burns CPU time" to a "real sleep, let other tasks use CPU".
I think it is accurate to say that NXC only frees up the CPU during a wait if you are targetting the V1.28 (or higher) ENHANCED FIRMWARE. If NXC code is compiled for, and loaded onto, the standard firmware then I believe that you still get the busy wait.

Ron.

Re: NBC speed

Posted: 17 May 2011, 22:40
by gloomyandy
So the obvious question is why do you need higher resolution then the timer gives you... What is it you are trying to do? If you explain the underlying problem someone may be able to help...