This is a static copy of a profile report

Home

imformats (Calls: 20, Time: 0.008 s)
Generated 16-Jul-2020 17:09:38 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/imagesci/imformats.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
imwrite>parse_inputssubfunction10
imwritefunction10
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
129
varargout{1} = find_in_registr...
200.005 s61.1%
67
[varargin{:}] = convertStrings...
200.001 s7.5%
160
mlock;
200.001 s6.4%
113
elseif (isequal(lower(varargin...
200.000 s4.0%
74
if (isempty(fmts))
200.000 s3.1%
All other lines  0.002 s18.0%
Totals  0.008 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
imformats>find_in_registrysubfunction200.004 s49.4%
Self time (built-ins, overhead, etc.)  0.004 s50.6%
Totals  0.008 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function160
Non-code lines (comments, blank lines)111
Code lines (lines that can run)49
Code lines that did run20
Code lines that did not run29
Coverage (did run/can run)40.82 %
Function listing
time 
Calls 
 line
   1 
function varargout = imformats(varargin)
   2 
%IMFORMATS  Manage file format registry.
   3 
%   FORMATS = IMFORMATS returns a structure containing all of the values in
   4 
%   the file format registry.  The fields in this structure are:
   5 
%
   6 
%        ext         - A cell array of file extensions for this format
   7 
%        isa         - Function to determine if a file "IS A" certain type
   8 
%        info        - Function to read information about a file
   9 
%        read        - Function to read image data from a file
  10 
%        write       - Function to write MATLAB data to a file
  11 
%        alpha       - 1 if the format has an alpha channel, 0 otherwise
  12 
%        description - A text description of the file format
  13 
% 
  14 
%   The values for the isa, info, read, and write fields must be functions
  15 
%   which are on the MATLAB search path or function handles.
  16 
%
  17 
%   FORMATS = IMFORMATS(FMT) searches the known formats for a format with
  18 
%   extension given in the character vector or string scalar "FMT."  If
  19 
%   found, a structure is returned containing the characteristics and
  20 
%   function names.  Otherwise an empty structure is returned.
  21 
% 
  22 
%   FORMATS = IMFORMATS(FORMAT_STRUCT) sets the format registry to contain
  23 
%   the values in the "FORMAT_STRUCT" structure.  The output structure
  24 
%   FORMATS contains the new registry settings.  See the "Warning" statement
  25 
%   below.
  26 
% 
  27 
%   FORMATS = IMFORMATS('add', FORMAT_STRUCT) adds the values in the
  28 
%   "FORMAT_STRUCT" structure to the format registry.
  29 
%
  30 
%   FORMATS = IMFORMATS('factory') resets the file format registry to the
  31 
%   default format registry values.  This removes any user-specified
  32 
%   settings.
  33 
%
  34 
%   FORMATS = IMFORMATS('remove', FMT) removes the format with extension
  35 
%   FMT from the format registry.
  36 
%
  37 
%   FORMATS = IMFORMATS('update', FMT, FORMAT_STRUCT) change the format
  38 
%   registry values for the format with extension FMT to have the values
  39 
%   stored in FORMAT_STRUCT.
  40 
% 
  41 
%   IMFORMATS without any input or output arguments prettyprints a table of
  42 
%   file format information for the supported formats.
  43 
%
  44 
%   Warning:
  45 
%
  46 
%     Using IMFORMATS to change the format registry is an advanced feature.
  47 
%     Incorrect usage may prevent loading of image files.  Use IMFORMATS
  48 
%     with the 'factory' setting to return the format registry to a workable
  49 
%     state. 
  50 
%   
  51 
%   Note:
  52 
%
  53 
%     Changes to the format registry do not persist between MATLAB sessions.
  54 
%     To have a format always available when you start MATLAB, add the
  55 
%     appropriate IMFORMATS commands to the startup.m file in
  56 
%     $MATLAB/toolbox/local. 
  57 
%
  58 
%   See also IMREAD, IMWRITE, IMFINFO, PATH.
  59 

  60 
%   Copyright 1984-2019 The MathWorks, Inc.
  61 

  62 
% Verify correct number of arguments
< 0.001 
     20 
  63
narginchk(0, 3); 
< 0.001 
     20 
  64
nargoutchk(0, 1); 
  65 

< 0.001 
     20 
  66
if nargin > 0 
< 0.001 
     20 
  67
    [varargin{:}] = convertStringsToChars(varargin{:}); 
< 0.001 
     20 
  68
end 
  69 

  70 
% Declare format structure as persistent variable
< 0.001 
     20 
  71
persistent fmts; 
  72 

  73 
% If format structure is empty (first time)
< 0.001 
     20 
  74
if (isempty(fmts)) 
  75 
  
  76 
    % Build default format structure
  77 
    fmts = build_registry;
  78 
    mlock
  79 
    
< 0.001 
     20 
  80
end 
  81 

  82 
% Determine what to do based on number of input arguments
< 0.001 
     20 
  83
switch(nargin) 
< 0.001 
     20 
  84
case 0 
  85 
    % 0 inputs: Informational only
  86 
    
  87 
    if (nargout == 0)
  88 

  89 
        % Pretty-print the registry
  90 
        pretty_print_registry(fmts)
  91 
        
  92 
    else
  93 
      
  94 
        % Return the registry as a struct
  95 
        varargout{1} = fmts;
  96 
        
  97 
    end
  98 
    
< 0.001 
     20 
  99
case 1 
 100 
    % 1 input: Look for specific format or modify registry
 101 
    
< 0.001 
     20 
 102
    if (isstruct(varargin{1})) 
 103 
      
 104 
        varargin{1} = matlab.io.internal.imagesci.convertStringsInStruct(varargin{1});
 105 
        % Change the registry to contain the structure
 106 
        fmts = update_registry(varargin{1});
 107 
        varargout{1} = fmts;
 108 
        
 109 
        % reset cached format from the last call of imread
 110 
        % as changes to imformats could have made it stale
 111 
        cachedFormat([]);
 112 
        
< 0.001 
     20 
 113
    elseif (isequal(lower(varargin{1}), 'factory')) 
 114 
      
 115 
        % Reset the registry to the default values
 116 
        fmts = build_registry;
 117 
        varargout{1} = fmts;
 118 

 119 
        % reset cached format from the last call of imread
 120 
        % as changes to imformats could have made it stale
 121 
        cachedFormat([]);
 122 

< 0.001 
     20 
 123
    elseif (ischar(varargin{1})) 
< 0.001 
     20 
 124
        if isempty(varargin{1}) 
 125 
            error(message('MATLAB:imagesci:imformats:badInputType'));
< 0.001 
     20 
 126
        end 
 127 
        
 128 
        % Look for a particular format in the registry
  0.005 
     20 
 129
        varargout{1} = find_in_registry(fmts, varargin{1}); 
 130 
        
 131 
    else
 132 
      
 133 
        % Error out, wrong input argument type
 134 
        error(message('MATLAB:imagesci:imformats:badInputType'))
 135 
        
< 0.001 
     20 
 136
    end 
 137 

 138 
otherwise
 139 
    % n inputs: Modify the registry using a command.
 140 

 141 
    command = validatestring(varargin{1},{'add','update','remove'});
 142 
    
 143 
    switch (lower(command))
 144 
        case 'add'
 145 
            fmts = add_entry(fmts, varargin{2:end});
 146 
        case 'update'
 147 
            fmts = update_entry(fmts, varargin{2:end});
 148 
        case 'remove'
 149 
            fmts = remove_entry(fmts, varargin{2:end});
 150 
    end
 151 
    varargout{1} = fmts;
 152 
    
 153 
    % reset cached format from the last call of imread
 154 
    % as changes to imformats could have made it stale
 155 
    cachedFormat([]);
 156 
    
< 0.001 
     20 
 157
end 
 158 

 159 
% Protect current file's persistent variables from CLEAR
< 0.001 
     20 
 160
mlock; 

Other subfunctions in this file are not included in this listing.