Main Site Documentation

Emulator performance


Every time I run the following (simple in my opinion) code the emulator starts to use all cpu power on one of my cores.


namespace ChipworkX_Application1
    public class Program
        public static void Main()
            int runCount = 0;
            while (true)

                if (runCount >= 100000)
                    runCount = 0;


It feels like a dump question, but why does that happen and how does it translate to real hardware?
I know a loop like this will run as fast as it can possibly go on a system using any and all resources. But as it is running in a emulator for small devices, I expect that my core i7 cpu should not even break a sweat. Also the output to the debug window feels slow. I expected hardware like the chipworks platform to run code like this so fast I wont even see the text move (if I would send it to lcd).

Anyone want to enlighten me?


For a loop like that it is normal. It doesn’t matter what cpu it is running on, it is still going to keep it busy 100%. Even for emulator.

Add a small Thread.Sleep() and see how much of a difference it will make.


What you say is true. I added an Thread.Sleep(1) and the cpu usage is way down. However the program is still running slower than expected. With a sleep of 1ms and a loop that must run 100000 times I get that I added a little over 1.5 minutes of waiting time between each hello world. In reality the emulator takes about 4 minutes before even de first hello world shows up. I might get 2 minutes for overhead but not more. Should I expect the same on real hardware or not?

I’m trying to assertain the performance of a program I wrote on real hardware and without profiling I can’t thing of something better. My real program runs way to slow on the emulator (emulation an old cpu), and I can’t find a way to determine if that is representative of the chipworkx platform or just lousy emulator performance.


Sorry to break your bubble, but you can’t expect the emulator to give you relative performance indications.

For example, it has to emulate the way a 72mhz EMX (or slower chip) works as well as how a ChipworkX at 200mhz works; it can’t know what your target hardware platform will be to “change” it’s behaviour.

If your app is slow on the emulator it’ll be “slow” on hardware. Whether that’s an issue or not you won’t be able to tell. And the code you show below is not a good test anyway; you’re using strings which can have a significant GC impact, and using debug calls which you wouldn’t do in a release version.

The only real way you can do performance is on the metal (well on the silicon).

I’m sure lots of people here can help suggest ways to improve performance if we know more about your application


I just tested on my laptop. Your original code took ~9sec per “hello world” loop in the emulator.

Then I ran it on a Panda (72mhz USBizi 100). It took under 4sec per loop.


Thank you all for your responses.

Brett, consider the bubble burst. Time to invest in the hardware I guess. I appreciate that you tried to run my “testing” code through a the emulator and you panda. Aparently the panda acts twice as quick as the emulator. I would not have expected that. I would expect the emulator to be faster. The times I get on the emulator are far slower however. I gues that must be something to do with my machine. I’ll look in to that.


I’m not sure you can say “the panda is twice as fast as the emulator”. Your emulator vs my emulator aren’t the same, and I doubt they ever would be. Perhaps you can tweak your machine and improve your emulator’s performance, but who says my machine also can’t be tweaked to “improve” it - who knows if someone’s machine isn’t already faster than a hardware platform. And again I don’t think the emulator is trying to represent hardware of any particular performance - you’re never going to get a good indication of “absolute” performance in the emulator.

What you can find though is that if you improve the perf of an app in the emulator through revising your code, you’ll get benefit on the hardware. So from that perspective you can still use it to improve your code.

If you want to post code (or a project) and have someone post results on a hardware platform, I’m sure people will oblige. There are some other threads about capturing performance data that you might use to build some metrics into your application too.