source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/test_flops.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.4 KB
Line 
1if 0
2  % run under matlab 5
3  a = rand(2,3);
4  b = rand(3,4);
5  c = rand(3);
6  flops(0); a+a; flops
7  flops(0); a.*a; flops
8  flops(0); a./a; flops
9  flops(0); a<a; flops
10  flops(0); exp(a); flops
11  flops(0); log(a); flops
12  flops(0); a*a'; flops
13  flops(0); a*b; flops
14  flops(0); a/b'; flops
15 
16  ns = 1:10;
17  f = [];
18  for n = ns
19    c = rand(n);
20    c = c*c';
21    flops(0); chol(c); f(n) = flops;
22  end
23  f = [1 5 14 30 55 91 140 204 285 385];
24  x = [ones(size(ns)); ns; ns.^2; ns.^3];
25  a = f/x
26  plot(ns,f - a*x)
27end
28
29niter = 2000;
30a = rand(100);
31b = rand(100);
32if 0
33  tic; for i=1:niter ones(100); end; t_ones=toc/niter;
34  fprintf('time for ones: %g\n', t_ones);
35else
36  t_ones = 0;
37end
38t = [];
39tic; for i=1:niter a+4; end; t(1)=toc/niter;
40tic; for i=1:niter a+b; end; t(2)=toc/niter;
41tic; for i=1:niter a.*b; end; t(3)=toc/niter;
42t_arith = mean(t) - t_ones;
43fprintf('average for +,*: %g\n', t_arith);
44if 0
45  % By time, == takes 2 flops, but this is processor dependent.
46  t = [];
47  tic; for i=1:niter a>b; end; t=toc/niter;
48  fprintf('time for >: %g\tflops = %g (should be %g)\n', t, t/t_arith, 2);
49  %tic; for i=1:niter a==b; end; t=toc/niter;
50  tic; for i=1:niter a~=b; end; t=toc/niter;
51  fprintf('time for ~=: %g\tflops = %g\n', t, t/t_arith);
52end
53if 0
54  tic; for i=1:niter randn(100); end; t=toc/niter;
55  t = t-t_ones;
56  fprintf('time for randn: %g\tflops = %g\n', t, t/t_arith);
57end
58if 0
59  tic; for i=1:niter a.^(0.51); end; t=toc/niter;
60  e1 = exp(1);
61  tic; for i=1:niter e1.^a; end; t=toc/niter;
62  t = t-t_ones;
63  fprintf('time for pow: %g\tflops = %g\n', t, t/t_arith);
64  if 0
65    tic; for i=1:niter a.^(0.5); end; toc
66    tic; for i=1:niter sqrt(a); end; toc
67  end
68end
69tic; for i=1:niter sqrt(a); end; t_sqrt=toc/niter;
70fprintf('time for sqrt: %g\tflops = %g (should be %g)\n', t_sqrt, t_sqrt/t_arith, flops_sqrt);
71tic; for i=1:niter exp(a); end; t_exp=toc/niter;
72fprintf('time for  exp: %g\tflops = %g (should be %g)\n', t_exp, t_exp/t_arith, flops_exp);
73tic; for i=1:niter pow2(a); end; t_pow2=toc/niter;
74fprintf('time for pow2: %g\tflops = %g (should be %g)\n', t_pow2, t_pow2/t_arith, flops_exp);
75tic; for i=1:niter log(a); end; t_log=toc/niter;
76fprintf('time for  log: %g\tflops = %g (should be %g)\n', t_log, t_log/t_arith, flops_log);
77tic; for i=1:niter log2(a); end; t_log=toc/niter;
78fprintf('time for log2: %g\tflops = %g (should be %g)\n', t_log, t_log/t_arith, flops_log);
Note: See TracBrowser for help on using the repository browser.