summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scilab/modules/core/tests/benchmarks/mandelbrot_naive.tst54
-rw-r--r--scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst49
2 files changed, 103 insertions, 0 deletions
diff --git a/scilab/modules/core/tests/benchmarks/mandelbrot_naive.tst b/scilab/modules/core/tests/benchmarks/mandelbrot_naive.tst
new file mode 100644
index 0000000..d0b3fbf
--- /dev/null
+++ b/scilab/modules/core/tests/benchmarks/mandelbrot_naive.tst
@@ -0,0 +1,54 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
4// Copyright (C) 2011 - DIGITEO - Mickael BAUDIN
5//
6// This file is distributed under the same license as the Scilab package.
7// =============================================================================
8
9//==============================================================================
10// Naive mandelbrot benchmark
11//==============================================================================
12
13// <-- BENCH NB RUN : 3 -->
14
15function R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax)
16 xvect = linspace( xmin, xmax, xsize );
17 yvect = linspace( ymin, ymax, ysize );
18 R = zeros(xsize,ysize);
19 for i = 1:xsize
20 for j = 1:ysize
21 x = xvect(i);
22 y = yvect(j);
23 x0 = x;
24 y0 = y;
25 k = 0;
26 while( x*x + y*y < 4 & k < nmax )
27 xtemp = x*x - y*y + x0;
28 y = 2*x*y + y0;
29 x = xtemp;
30 k=k+1;
31 end
32 if k<nmax then
33 R(i,j) = k;
34 else
35 R(i,j) = -1;
36 end
37 end
38 end
39endfunction
40
41xsize = 50;
42ysize = 50;
43nmax = 1000;
44xmin = 0.2675;
45xmax = 0.2685;
46ymin = 0.591;
47ymax = 0.592;
48
49// <-- BENCH START -->
50
51R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax);
52
53// <-- BENCH END -->
54
diff --git a/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst b/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst
new file mode 100644
index 0000000..f0789fd
--- /dev/null
+++ b/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst
@@ -0,0 +1,49 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
4// Copyright (C) 2011 - DIGITEO - Mickael BAUDIN
5//
6// This file is distributed under the same license as the Scilab package.
7// =============================================================================
8
9//==============================================================================
10// Naive mandelbrot benchmark
11//==============================================================================
12
13// <-- BENCH NB RUN : 30 -->
14
15function R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax)
16 xvect = linspace( xmin, xmax, xsize );
17 yvect = linspace( ymin, ymax, ysize );
18 [X,Y]=meshgrid(xvect,yvect);
19
20 Z = zeros(xsize,ysize);
21 R = -ones(xsize,ysize);
22 W = zeros(xsize,ysize);
23 C=X+%i*Y;
24 J = 1:xsize*ysize;
25 for k=0:nmax
26 L = J(J>0);
27 Z(L) = Z(L).^2+C(L);
28 W(L) = abs(Z(L));
29 M = find(W(L)>2);
30 R(L(M)) = k;
31 J(L(M)) = 0;
32 end
33 R = R';
34endfunction
35
36xsize = 50;
37ysize = 50;
38nmax = 1000;
39xmin = 0.2675;
40xmax = 0.2685;
41ymin = 0.591;
42ymax = 0.592;
43
44// <-- BENCH START -->
45
46R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax);
47
48// <-- BENCH END -->
49