diff m-toolbox/classes/+utils/@helper/CPUbenchmark.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@helper/CPUbenchmark.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,42 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% CPU benchmarking for comparing speeds among different
+% architectures/computers.
+%
+% DESCRIPTION: CPUbenchmark provides a benchmark CPU time for comparison
+%              among different architectures/computers. It gives the mean
+%              CPU time and the mean error.
+%
+% CALL:        [a, b] = CPUbenchmark;
+%
+% VERSION:     $Id: CPUbenchmark.m,v 1.1 2011/02/03 13:34:47 congedo Exp $
+%
+% HISTORY:     02-02-2011 G. Congedo
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function [avgT,stdT]=CPUbenchmark
+
+ avgT = zeros(10,1);
+ stdT = avgT;
+
+ for jj=1:10
+  m = zeros(100,1);
+  for kk = 1:100
+    tic
+    for i = 1:1e4
+    a = rand(10,10);
+    a = a';
+    end
+    m(kk)=toc;
+  end
+
+  avgT(jj) = mean(m);
+  stdT(jj) = std(m)/sqrt(numel(m));
+  
+ end
+ 
+ avgT = mean(avgT);
+ stdT = mean(stdT);
+
+end
\ No newline at end of file