]> Creatis software - CreaPhase.git/blob - octave_packages/benchmark-1.1.1/benchmark_permute.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / benchmark-1.1.1 / benchmark_permute.m
1 % Copyright (C) 2009  VZLU Prague
2
3 % This file is part of OctaveForge.
4
5 % OctaveForge is free software; you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation; either version 2 of the License, or
8 % (at your option) any later version.
9
10 % This program is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 % GNU General Public License for more details.
14
15 % You should have received a copy of the GNU General Public License
16 % along with this software; see the file COPYING.  If not, see
17 % <http://www.gnu.org/licenses/>.
18
19
20 % function benchmark_permute (n)
21 % description:
22 % Test speed of array permuting.
23 %
24 % arguments:
25 % n = dimension size (n^5 is number of elements)
26 %
27 % results:
28 %
29 % time_21345 = time for [2,1,3,4,5] permutation
30 % time_13425 = time for [1,3,4,2,5] permutation
31 % time_34125 = time for [3,4,1,2,5] permutation
32 % time_45123 = time for [4,5,1,2,3] permutation
33 %
34
35 function results = benchmark_permute (n, rep)
36
37   benchutil_default_arg ('n', 30);
38
39   benchutil_initialize (mfilename)
40
41   a = zeros (n, n, n, n, n);
42
43   tic; b = permute (a, [2,1,3,4,5]); time_21345 = toc
44   benchutil_set_result ('time_21345')
45   
46   tic; b = permute (a, [1,3,4,2,5]); time_13425 = toc
47   benchutil_set_result ('time_13425')
48   
49   tic; b = permute (a, [3,4,1,2,5]); time_34125 = toc
50   benchutil_set_result ('time_34125')
51
52   tic; b = permute (a, [4,5,1,2,3]); time_45123 = toc
53   benchutil_set_result ('time_45123')
54