MACRO: List All Macros By Size

List All Macros By Size

I don't think anyone's written this yet, so here it is.


Name: List All Macros By Size
Version: 1.0.1
Updated: 2022/02/11 07:29 PT
By: Dan Thomas

PURPOSE:

Lists all macros sorted by size, in a window. The actual output is:

Size tab MacroName tab GroupName

May take a little while to run, depending on the hardware, and number of macros. Not too long, but it isn't instantaneous.

NOTES:

  • The size includes the size of the custom icon, if any.
  • The size reported is only valid for comparison purposes:
    • It doesn't match the actual compressed size of the XML data.
    • It doesn't match amount of actual memory a macro takes up.

VERSION HISTORY:

1.0.1 - Fixed an issue with some older macOS versions.
1.0 - Initial version.


List All Macros By Size.v1.0.1.kmmacros (32.6 KB)

7 Likes

Dan,
this is amazing. Thank for the hard work.

1 Like

It's an amazing and informative utility. The program outputs the size of each macro in bytes. But I have two questions: (1) does this include the data used by images within the macros? (2) how would I estimate the "percentage" each macro is using rather than each macro's total bytes? Perhaps what I want to know is: what's the easiest way to add up the numbers from your output?

Thanks, "Ph.Dan."

1 Like

Yes, it includes all that info. As for what's the easiest way to add the numbers up and figure out percentages, sounds like a job for a spreadsheet. Should be too hard, since the data is tab-delimited.

Sleepy,
Since this piece of amazing work by Dan is so useful, I use Dan's output listing to generate a formatted report with size percent column.


[KBM] List All Macros By Size_formatted_report.kmmacros (36.0 KB)

Updated to Dan's code v1.0.1

4 Likes

Thanks for that. Looks great. I find percentages to be more meaningful when I'm trying to trim some fat.

@DanThomas and @macdevign_mac very nice work, thank you for putting this together. I believe it will help me when I periodically do housecleaning!

On an interesting note... two of my five largest macros are your's Dan... :laughing:

2.95%	|	291,808	|	45)[VIP] Setup Variable Inspector Prompt - Advanced (Subroutine)	|	VIP - Variable Inspector Prompt
1.57%	|	154,856	|	09)[AS:KM] Palette Organizer									|	App Specific: Keyboard Maestro                    

I have a 5 megabyte macro which contains an action with a text constant that's 4.5 megabytes in size. :slight_smile: I suppose I should store the text in a file instead, and read it when the macro initializes.

Obviously I created that large macro intentionally, but I forgot about it, so this utility is helpful for me to spot my biggest mistakes.

1 Like

:scream: That is quite large! :laughing:

Now I'm curious to see who around here has the largest macro library :sweat_smile:

Since this produces no output at all on my system @DanThomas I assume it requires Monterey? Is that correct?

KM Log contains:

2022-02-11 13:29:32 Action 526658 failed: Execute a JavaScript For Automation failed with script error: text-script:3096:3148: script error: Error on line 90: SyntaxError: Unexpected token '?' (-2700)
2022-02-11 13:29:32 Execute a JavaScript For Automation failed with script error: text-script:3096:3148: script error: Error on line 90: SyntaxError: Unexpected token '?' (-2700) in macro “List All Macros By Size” (while executing Execute JavaScript For Automation).

I can't get it working either. I'm on Big Sur and KM 10.0.2.

This is the error I got.

@tiffle and @kcwhat I'm on Big Sur (11.6.3) and KM 10.0.2 and it's working for me...

@cdthomer -

I guess I'll miss out on this one. Looks like an incredible macro.

I'm sure Dan will come up with a solution. He always works hard to make his macros work for everybody.

1 Like

I know but sometimes Dan needs a break. I hesitated to even respond that it wasn't working for me as I tried it several times. Since it works for others, there must be something crazy about my system. I truly don't want to occupy his time. I'll miss out on this one and it's ok. :slight_smile:

2 Likes

Maybe if we offer him twice his usual fee for writing macros for us, he might accommodate us.

2 Likes

Twice as many Internet accolades then? :sweat_smile:

1 Like

In my case, 7 out of the 9 largest macros are created by Dan. :laughing:

1 Like

The Variable Inspector Prompt is that large because it has the HTML in one of the actions. You can actually put the HTML in a file if you want to. At the end of the macro 45)[VIP] Setup Variable Inspector Prompt - Advanced (Subroutine) is this code:

image

 
Take the HTML from #1 (above) and put it in a file. Set variable #2 to the file path. Then, at the minimum, delete or clear out #1.

As for any of my other macros, delete the icons - that's usually where the size comes from. Especially in things like KMFAM, which has icons on a lot of the individual macros, and the group.

(And I know you weren't necessarily complaining, but since I have a solution, I thought I'd mention it.)

2 Likes

Fixed in version 1.0.1, in the original post.

1 Like