Code covered by the BSD License  

Highlights from
Display ws variables size in KB, MB or GB

4.5

4.5 | 4 ratings Rate this file 10 Downloads (last 30 days) File Size: 3.49 KB File ID: #26250
image thumbnail

Display ws variables size in KB, MB or GB

by

 

02 Jan 2010 (Updated )

Displays with appropriate unit of data storage. Sorting by size/name (non c.sensitive) is supported.

| Watch this File

File Information
Description

Display in command window the size of the variables of the base workspace using KB, MB and GB

SYNTAXES:
(1) WSSIZE Display preserving the order of the workspace pane using mixed units
(2) WSSIZE arg or WSSIZE('arg') One argument syntax
(3) WSSIZE arg1 arg2 or WSSIZE('arg1','arg2') Two arguments syntax

From p7v5 displays the grand total.

Arguments: should be char; max two arguments are allowed. Arguments are not case-sensitive.The order of the two types of arguments doesn't matter. Shortened arguments can be supplied ('s' instead of 'size').

For details see help
For examples see the attached image.

Aknowledgments: original idea by Bastiaan Zuurendonk, TMW technical support engineer. Implemented suggestions by Yair Altman (see comments)

Comments/suggestions/error reports are welcome.
p7v5

MATLAB release MATLAB 7.9 (R2009b)
Other requirements Tested on R14SP3 (7.1) and on R2009b. In-between compatibility is assumed.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
17 Sep 2013 Casper  
17 Feb 2010 Oleg Komarov

You're suggestion to subject the Grand Total to the reverse sorting behaviour?...I'd implement it always as the last entry because when you have many variables the listing on the screen scrolls down a lot...and I'd like to know at a glance how much memory I'm using. Revsorting would flip GT on top and i would miss it...

What about
a: 432 KB
b: 23 KB
========
T: 455 KB

Where "a" and "b" are subject to the sorting while T: is not?

17 Feb 2010 Michael

Nice and usefull tool. Exactly what I was looking for. I would also find an entry "Grand Total" helpful, for example by adding the lines
ws_contents(end+1,:) = { 'Grand Total', sum( cell2mat(ws_contents(:,2)) )};
numVars = numVars+1;
after line 95.

16 Jan 2010 Rob Campbell

Always wanted this behaviour from whos. Glad to find this file.

08 Jan 2010 Oleg Komarov

Andy,
you're are totally right if syntax consistancy is what we are looking for...and it may be, but when I set the default behavior for the size sorting method I was thinking that maybe displaying first the biggest vars would save some time (if you already have 50 other vars and to see them all scrolling is needed).
On the other hand as you say 'wssize -s' isn't that different from 'wssize s'...I simply didn't want to write every time '-s' (since i'm inerested in many cases in large vars.).
To make it consistent accross methods or not...this is my dilemma..

07 Jan 2010 Andy

A minor point: I would switch the size and -size flags so that wssize size sorts from smallest to largest. This is consistent with wssize name sorting in ascending order and wssize -name sorting in descending order.

07 Jan 2010 Oleg Komarov

Thanks Yair for the comments (of course I will implement your java suggestion, since that was what I wanted specifically to achieve, still this fcn remains useful)
The features suggested by Yair are being uploaded. Additionally, the workspace variables whose data size will be displayed will change from 'base' to 'caller', making it possible to display the size of the variables during debug. Other updates will be notified in the update frame (below) and inside the fcn. Compatibility unchanged.
Oleg

05 Jan 2010 Yair Altman

Nice and useful implementation.

I suggest adding reverse sorting by simply prepending '-' (for example: '-size'). I also suggest adding an option to display all the sizes in a particular format (for example: 'KB' or 'MB').

Also see http://undocumentedmatlab.com/blog/customizing-matlabs-workspace-table/ for how to display similar results in the Workspace Panel table.

Updates
05 Jan 2010

Edited description; Added sorting by not case-sensitive name; Aknowledgments for Bastiaan Zuurendonk (TMW technical support engineer)

06 Jan 2010

Added reverse sorting and unit selection on suggestion by Yair Altman. Edited help. Added more checks.

07 Jan 2010

From 'base' to 'caller' size display.

15 Jan 2010

Now 'size' sorts from smallest to biggest. Suggestion by Andy.

22 Feb 2010

Per Michael suggestion added grand total at the bottom. Restructured code.

Contact us