MatrixBerryCore
ProfileInfoDetailed.m
Go to the documentation of this file.
1 classdef ProfileInfoDetailed<mxberry.dev.prof.ProfileInfo
2 
3  properties (Access=private,Hidden)
4  % detailed profile info
5  StProfileInfo
6  end
7 
8  methods
9  function self=ProfileInfoDetailed()
10 
11  self=self@mxberry.dev.prof.ProfileInfo();
12  self.StProfileInfo=[];
13  end
14 
15  function tic(self)
16 
17  self.StProfileInfo=[];
18  tic@mxberry.dev.prof.ProfileInfo(self);
19  profile on;
20  end
21 
22  function resTime=toc(self)
23 
24  resTime=toc@mxberry.dev.prof.ProfileInfo(self);
25  if isempty(self.StProfileInfo)
26  profile off;
27  self.StProfileInfo=profile('info');
28  end
29  end
30 
31  function StProfileInfo=getProfileInfo(self)
32  import mxberry.core.throwerror;
33  if isempty(self.StProfileInfo)
34  throwerror('wrongInput',...
35  'You must call TOC before calling getProfileInfo');
36  end
37  StProfileInfo=self.StProfileInfo;
38  end
39  function resTime=process(self,varargin)
40  import mxberry.core.throwerror;
41  %
42  mxberry.core.checkvar(self,'isscalar(x)');
43  %
44  %% initial actions
45  [reg,callerName,profileDir,profileMode,isCallerNameSpec,...
46  isProfileDirSpec]=...
47  mxberry.core.parseparext(varargin,...
48  {'callerName','profileDir','profileMode';...
49  [],[],'file';
50  'isstring(x)','isstring(x)||ischar(x)&&isempty(x)',...
51  'isstring(x)'},[1 2],...
52  'regCheckList',...
53  {'isstring(x)',...
54  'isstring(x)'},...
55  'regDefList',{[],'default'});
56  %
57  if ~isCallerNameSpec
58  callerName=mxberry.core.getcallername();
59  end
60  if ~isProfileDirSpec
61  profileDir=fileparts(which(callerName));
62  end
63  %
64  if ~isempty(reg)
65  profCaseName=reg{1};
66  else
67  profCaseName='default';
68  end
69  %% process profiling results
70  resTime=self.toc();
71  %
72  SProfileInfo=self.getProfileInfo();
73  switch lower(profileMode)
74  case 'viewer'
75  profCaseName=[callerName,'.',profCaseName];
77  SProfileInfo,'titlePrefix',profCaseName);
78  %
79  case 'file'
80  %
81  profName=[callerName,...
82  filesep,profCaseName,...
83  filesep,datestr(now(),'dd-mmm-yyyy_HH_MM_SS_FFF')];
84  profDir=[profileDir,filesep,'profiling',filesep,profName];
86  SProfileInfo,profDir);
87  otherwise
88  throwerror('wrongInput',...
89  'profMode %s is not supported',profileMode);
90  end
91  end
92  end
93 end
function filesep()
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function parseparext(in args, in propNameValMat, in varargin)
PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more...
function checkvar(in x, in typeSpec, in varargin)
CHECKVAR checks a generic condition provided by typeSpec string in the following format: &#39;isnumeric(x...
PROFILEINFO contains profiling info obtaining during exectution of some code.
Definition: ProfileInfo.m:5
function profView(in varargin)
PROFVIEW enhances a functionality of Matlab built-in function profview by allowing to display several...
function profSave(in SProfileInfo, in dirName)
PROFSAVE does the same as the built-in profsave function except for displaying the saved report in th...
PROFILEINFODETAILED contains detailed profiling info obtaining during exectution of some code...