Created
May 17, 2012 20:04
-
-
Save sajith/2721280 to your computer and use it in GitHub Desktop.
silly Matlab function to show load times of .mat files under a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadtimes ( dirname ) | |
if isempty ( dirname ), return, end | |
cmd = sprintf ( 'find %s -iname "*.mat"', dirname ); | |
[ ~, files ] = system ( cmd ); | |
mfiles = regexp ( files, '\n', 'split'); | |
for i = 1 : length ( mfiles ) - 1 | |
s1 = sprintf ( '%s', mfiles{i} ); | |
s = regexprep ( s1, ',$', '' ); | |
d = dir ( s ); | |
fprintf ( '%s, %s, %d bytes, \t', s, bytes2h ( d.bytes ), d.bytes ); | |
tic; load ( s ); toc; | |
end | |
return | |
function [sz] = bytes2h ( bytes ) | |
if ( bytes < 1024 ) | |
sz = sprintf ( '%d bytes', bytes ); | |
elseif ( bytes < 1024 * 1024 ) | |
sz = sprintf ('%0.2f KiB', bytes / 1024 ); | |
elseif ( bytes < 1024 * 1024 * 1024 ) | |
sz = sprintf ('%0.2f MB', bytes / ( 1024 * 1024 ) ); | |
end | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment