Arrays? Defining Components

@ cncmike. The light will come on. Before c#, there was darkness :slight_smile:

Just ask some specific questions when you need. cheers.

Yes, please ask!I make mistakes too, but I learn a lot from them. You can read books, but you will never forget those mistakes :wink:

I consider myself to be a very experienced… I have made more mistakes than most.

Don’t worry all, I will be asking. This Panda is consuming all my free time. I have a brand new garage that needs wiring, but I am HOOKED on this stuff right now.

When I go I got the Jens Kuhners book Expert .NET Micro Framework" open on PDF, with component PDFs and FEZ drivers along with Microsoft’s MSDN website up. (Lucky I got 2-22" Wide Screens hooked up)

Hoping either to find a source how to put it all together or waiting for it to click, but making progress trying anyways.

(Got temperature sensor component to send RS232 temp reading to computer, that was cool!! Right now reading on TeraTerm, but also working on a C# Windows Form to Capture and Display, maybe even request in time)

Thanks,

Mike in MN

Just started playing with the Panda. This thread Brings up a question with c# and micro frame work. How does one evaluate the efficiency of the many different ways of handling objects. Maybe the object array leads to coding efficiency but how can one evaluate execution efficiency.

“Maybe the object array leads to coding efficiency but how can one evaluate execution efficiency.”

A for loops and casting are some of the fastest operations you can do, so not sure it is worth looking at in general. Spend your time perf tuning where and when you find something that would actually benefit from tuning. Most of your cpu time is spent sleeping or blocking anyway unless your running pi out in a tight loop. Even in a PID controller your sleeping at the bottom to slow it down. Another thing would be how would you handle this without an array? 10 if tests every time you want to check all items? Generics would save the casting, but probably will not see MF generics until cobra type avail memory is the watermark level.

But to answer your question. Perf testing is normally done with a timer or TimeSpan. Take the DateTime before and after and subtract to get a TimeSpan. Something like:

var array = new int[] {1,2,3,4,5,6,7,8,9,10 };
var start = DateTime.Now;
int count = 0;
while(count<10000)
{
    for (int i = 0; i < array.Length; i++)
        count++;
}
var time = DateTime.Now - start;
Debug.Print("Time to run:" + time.ToString());