CPU Load

Discussion to talk about software related topics only.
Post Reply
mwood
Posts: 6
Joined: Mon Feb 01, 2010 1:13 pm

CPU Load

Post by mwood »

My netburner application has grown quite large and I'm having concerns that the cpu may be overloaded so I would like to be able to monitor cpu usage. I've looked through the documentation and haven't found anything helpful, maybe I'm overlooking something. This would seem to be a common issue. Does someone know a good way to measure the cpu load?
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: CPU Load

Post by tod »

A quick way to monitor is to have the lowest priority task in your app (or create an add'l task for this purpose) wake up every tick (or less frequently if you really think the CPU is starving) and do something like std::cout <<"."; You can tell quite a bit from the frequency of the dots. If you're CPU starved you won't get any, if it's a really heavy load you aren't going to get as many as you expect. This is a fairly intrusive way to test but it's all I've ever needed.

You may want to create an empty project with this technique to get a baseline.
mwood
Posts: 6
Joined: Mon Feb 01, 2010 1:13 pm

Re: CPU Load

Post by mwood »

Thanks, I'll give it a shot. This may take a while to code since my app runs remotely and I don't have access to serial out. I'm using the web server for interaction so I'll need to put a "CPU Usage" indicator in the web page. I'll let you know how it goes.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: CPU Load

Post by Ridgeglider »

TWO methods: (from a previous post by Paul:)

edit nburn\include\predef.h and uncomment

#define UCOS_STACKCHECK (1)

Recompile everything.

1)By using taskscan:

#include <taskmon.h>

EnableTaskMonitor();

Then use the taskscan application (see C:\Nburn\docs\NetBurnerPcTools\NetBurnerTools.pdf).
This will report the stack usage, current and max on a per task basis. If you creat the tasks using either:
OSTaskCreatewName() or OSSimpleTaskCreatewName(), the name of each task will also be reported.

By the way NB folks, neither OSTaskCreatewName, nor OSSimpleTaskCreatewName() are described in
C:\Nburn\docs\NetBurnerRuntimeLibrary\uCOSLibrary.pdf although there is an example in C:\nburn\examples\RTOS\OSFlags\main.cpp

2)The other choice is to call

void OSDumpTCBStacks( void );
(see "OSDumpTCBStacks" in C:\Nburn\docs\NetBurnerRuntimeLibrary\uCOSLibrary.pdf )
This prints out stack info to stdout.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: CPU Load

Post by lgitlitz »

I have a time slice profile utility that may be helpful. What this does is trigger a level 7 interrupt at a certain time interval and record the address of the program counter. It will then print a list of the addresses and how many times each occurred out the debug port. You can then use the winaddr2line pc tool to determine what line of code the address corresponds to. This is set up for the 5270 platforms but should be easily converted for the ether platforms. It also should be somewhat easy to adjust the granularity of the counter if needed. There is a main.cpp in the zip file that demonstrates how this is used.
Attachments
TimeSliceProfiler.zip
(2.67 KiB) Downloaded 325 times
Post Reply