List All Macros By Size
I don't think anyone's written this yet, so here it is.
Name: List All Macros By Size
Updated: 2022/02/11 07:29 PT
By: Dan Thomas
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.
- 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.
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)
this is amazing. Thank for the hard work.
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?
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.
[KBM] List All Macros By Size_formatted_report.kmmacros
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.
Updated to Dan's code v1.0.1
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...
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. 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.
That is quite large!
Now I'm curious to see who around here has the largest macro library
Since this produces no output at all on my system @DanThomas I assume it requires Monterey? Is that correct?
KM Log contains:
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...
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.
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.
Maybe if we offer him twice his usual fee for writing macros for us, he might accommodate us.
Twice as many Internet accolades then?
In my case, 7 out of the 9 largest macros are created by Dan.
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:
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.)
Fixed in version 1.0.1, in the original post.