cputime seems to count serial computation time, while tic-toc does not

7 Ansichten (letzte 30 Tage)
xin
xin am 3 Mai 2011
The codes below will show the difference. But why? Does that mean, cputime calculates the time for serial computation and tic--toc for parallel or SPMD(Single Process, Multiple Data)? When using SPMD, is the computation in parallel? And if you can use "top" in your server to monitor the cpu usage, you will see usage is more than 100%, that means you are using more than 1 cpu to calculate. Mine cpu usage was 1147%.
clc;
clear;
tic
t=cputime;
N=4000;
all=magic(N);
b=all*all*all*all*all*all*all;
cpu_time=cputime-t
toc_time=toc
============================
My running result is:
cpu_time =
167.3800
toc_time =
14.8073
Because the cpu usage is 1147% for me, so toc_time*1147% is almost the cpu_time result. So I think the cputime calculates the serial computation time.

Antworten (1)

Jan
Jan am 3 Mai 2011
  2 Kommentare
xin
xin am 3 Mai 2011
I am building some my own functions to beat the matlab built-in functions. So I think the best way to compare is using cputime.
Matt Fig
Matt Fig am 3 Mai 2011
That conclusion apparently doesn't follow from your single premise...
Could you flesh out your reasoning a bit more?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by