]> Creatis software - CreaPhase.git/blob - octave_packages/benchmark-1.1.1/benchutil_parse_desc.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / benchmark-1.1.1 / benchutil_parse_desc.m
1 % Copyright (C) 2008  Jaroslav Hajek <highegg@gmail.com>
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 [bench_desc, arg_desc, result_desc] = benchutil_parse_desc (mpath)
21 % parse the inline comment description from a benchmark
22 %
23
24 function [bench_desc, arg_desc, result_desc] = benchutil_parse_desc (mpath)
25   fid = fopen (mpath, 'rt');
26   
27   line = ''; 
28   iseof = feof (fid);
29   while (~ (strncmp (line, '% description:', 14) || iseof))
30     line = fgets (fid);
31     iseof = feof (fid);
32   end
33
34   bench_desc = '';
35   line = fgets (fid);
36   iseof = feof (fid);
37   while (~ (strncmp (line, '% arguments:', 12) || feof (fid)))
38     %TODO fix
39     bench_desc = [bench_desc, line(3:end)];
40     line = fgets (fid);
41     iseof = feof (fid);
42   end
43
44   line = fgetl (fid);
45   iseof = feof (fid);
46   while (~ (strncmp (line, '% results:', 10) || feof (fid)))
47     i = strfind (line, ' = ');
48     if (~ isempty (i))
49       name = line (3:i(1)-1);
50       arg_desc.(name) = line (i(1)+3:end);
51     end
52     line = fgetl (fid);
53     iseof = feof (fid);
54   end
55
56   line = fgetl (fid);
57   iseof = feof (fid);
58   while (strncmp (line, '%', 1) && ~ feof (fid))
59     i = strfind (line, ' = ');
60     if (~ isempty (i))
61       name = line (3:i(1)-1);
62       result_desc.(name) = line (i(1)+3:end);
63     end
64     line = fgetl (fid);
65     iseof = feof (fid);
66   end
67
68   fclose (fid);
69