Thread Subject: how to get accurate timing on a CPU with multiple jobs

Subject: how to get accurate timing on a CPU with multiple jobs

From: Henry

Date: 25 Jul, 2009 05:48:01

Message: 1 of 2

I have a simple question for measuring how much CPU time is spent on a block of matlab code. The key challenge is that the CPU may have some other people's jobs running at the same time, and my job may get only 20% of the total time. The utilities provided by Matlab like "tic, toc, cputime, etime" are all for the case where the CPU is exclusively used by the single job. I have read posts like http://www.mathworks.com/matlabcentral/fileexchange/18798, but none of them deals with the case of multiple task on single CPU.

I am using a community cluster (with Linux) to run experiments, so this is a problem.

Thank you in advance.

Subject: how to get accurate timing on a CPU with multiple jobs

From: Yi Cao

Date: 1 Aug, 2009 09:37:00

Message: 2 of 2

"Henry " <hz.community@gmail.com> wrote in message <h4e6ah$kcn$1@fred.mathworks.com>...
> I have a simple question for measuring how much CPU time is spent on a block of matlab code. The key challenge is that the CPU may have some other people's jobs running at the same time, and my job may get only 20% of the total time. The utilities provided by Matlab like "tic, toc, cputime, etime" are all for the case where the CPU is exclusively used by the single job. I have read posts like http://www.mathworks.com/matlabcentral/fileexchange/18798, but none of them deals with the case of multiple task on single CPU.
>
> I am using a community cluster (with Linux) to run experiments, so this is a problem.
>
> Thank you in advance.

As I aware, tic, toc and cputime are not depend on physical time spend but to count actual CPU time exclusively used for the Matlab code. However, Matlab is mainly designed for a single CPU enviroment. For parallel computation, Matlab is not very efficient. In recent releases, Matlab is defaultly configured to use as many as possible CPUs when it starts. Therefore, when you use tic, toc, and cputime, you will fine the result is very high because although it use multiple CPUs, but the actual time is almost the same as use a single CPU. This means, if you have n cores, the result will be almost n times larger than the actual time if it runs in a single CPU environment.

To overcome the problem, you may wish to configure Matlab to only use one CPU. To do this, you can use the command

maxNumCompThreads(1)

It will also tell you how many CPUs Matlab actually used for this session.

HTH
Yi

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
timing Henry 25 Jul, 2009 01:49:02
rssFeed for this Thread

Contact us at files@mathworks.com