I will poke around as well, and see if I can find anything. I think there is a lot of utility in being able to time things running in native mode, instead of strictly running at "max speed".
Sorry to self-reply, but I may have found something useful - assuming that my understanding of SimpleNGen and wanderings through .NETMF have lead me in the correct direction.
My understanding of SimpleNGen is that it is generating opcodes for the processor, sticking them into an array, and then moving the IP to the beginning of that array when called. So, I would assume then that what you would need for timing is some sort of delay instruction block which your compiler could generate based on some function call which you compiled away.
I browsed through the .NETMF source (Specifically, starting at the new OneWire implementation - since I knew it required sub ms timings). It made a series of calls (usDelay in the OneWire library), which eventually ended up at AT91_TIME_Driver::Sleep_uSec() in the .NETMF code for the AT91 hardware (I assumed that this is the correct hardware for NetDuino).
This method is in the .NETMF 4.2 codebase at: client_v4_2_comm/DeviceCode/Targets/Native/AT91/DeviceCode/AT91_TIME/AT91_TIME.cpp
The code is here:
void __section(SectionForFlashOperations) AT91_TIME_Driver::Sleep_uSec( UINT32 uSec ) { GLOBAL_LOCK(irq); UINT32 value = AT91_TIMER_Driver::ReadCounter( AT91_TIMER_Driver::c_SystemTimer ); UINT32 maxDiff = CPU_MicrosecondsToTicks( uSec ); // The free-running timer clocks at a constant 3.25 MHz if(maxDiff <= AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS) maxDiff = AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS; else maxDiff -= AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS; while((AT91_TIMER_Driver::ReadCounter( AT91_TIMER_Driver::c_SystemTimer ) - value) <= maxDiff); }
Actually translating this into something directly useful to SimpleNGen is unfortunately beyond my knowledge of this hardware, firmware or memory layout. I am happy to break this into some slightly more useful code, if that is helpful, with things like actual memory addresses and constants instead of names - let me know. This is as far as I could get with notepad and grep on my work machine - pulling this all into an actual IDE will make it easier.
Hope this is generally the right direction!
--Jason