Profiling MT
You could check out this post: http://www.movabletype.org/2008/10/making_it_easier_to_debug_and_test_your_templates.html
I haven't used it with 5.X, so I can't tell you if it still works, but I would be interested to know.
Template examples
Using my test blog with 15,000 entries and 20 categories, I am not able to get your first code block to work correctly. First of all, I would expect you'd need to test all entries, not just the last 3, to be sure the results will be rigorous. Perhaps a really old entry is the first one sharing both categories.
I modified both your code blocks a bit to get what I think is your desired output of listing the last entry for each category that also shares a given category (in your case, "Comic", but in my test, "Top Story").
On my 5.13 installation, I found there is a difference between mt:EntryIfCategory
and mt:IfCategory
despite the documentation stating the former is deprecated in favor of the latter.
When I ran this code:
<mt:Categories>
<mt:Var name="show" value="1">
<mt:Entries lastn="99999">
<mt:If var="show" eq="1">
<mt:IfCategory label="Top Story">
Hello, <$mt:EntryTitle$>
<mt:Var name="show" value="0">
</mt:IfCategory>
</mt:If>
</mt:Entries>
</mt:Categories>
I only got output for one of the Categories
iterations, the one where the outer category matched the inner category. I am thinking IfCategory
is testing the outer Category
loop's category and not that of the inner Entries
loop. When I changed to EntryIfCategory
, it worked as expected.
So my final code was this (including a bunch of code I used for timing):
<mt:Section regex_replace="/^[\s]*$/mg","" regex_replace="/\n\n/mg","\n">
<mt:SetVarTemplate name="timingstart">
<$mt:Date format="%H" setvar="hours"$>
<$mt:Date format="%M" setvar="minutes"$>
<$mt:Date format="%S" setvar="seconds"$>
<$mt:Var name="hours" op="*" value="3600" setvar="hourseconds"$>
<$mt:Var name="minutes" op="*" value="60" setvar="minuteseconds"$>
<$mt:Var name="totalseconds" value="$hourseconds"$>
<$mt:Var name="totalseconds" op="+" value="$minuteseconds" setvar="totalseconds"$>
<$mt:Var name="totalseconds" op="+" value="$seconds" setvar="totalseconds"$>
<$mt:Var name="totalseconds" setvar="startseconds"$>
</mt:SetVarTemplate>
<mt:SetVarTemplate name="timingstop">
<$mt:Date format="%H" setvar="hours"$>
<$mt:Date format="%M" setvar="minutes"$>
<$mt:Date format="%S" setvar="seconds"$>
<$mt:Var name="hours" op="*" value="3600" setvar="hourseconds"$>
<$mt:Var name="minutes" op="*" value="60" setvar="minuteseconds"$>
<$mt:Var name="totalseconds" value="$hourseconds"$>
<$mt:Var name="totalseconds" op="+" value="$minuteseconds" setvar="totalseconds"$>
<$mt:Var name="totalseconds" op="+" value="$seconds" setvar="totalseconds"$>
<$mt:Var name="totalseconds" setvar="finishseconds"$>
<$mt:Var name="finishseconds" op="-" value="$startseconds" setvar="elapsedseconds">
This code block completed in <mt:If name="elapsedseconds" eq="0">less than 1 second<mt:Else name="elapsedseconds" eq="1">1 second<mt:Else><$mt:Var name="elapsedseconds"$> seconds</mt:If>.
</mt:SetVarTemplate>
++++++++++++++++++++++++++++++++++++++++++
<$mt:Var name="timingstart"$>
<mt:Categories>
<mt:Var name="show" value="1">
<mt:Entries lastn="99999">
<mt:If var="show" eq="1">
<mt:EntryIfCategory label="Top Story">
Hello, <$mt:EntryTitle$>
<mt:Var name="show" value="0">
</mt:EntryIfCategory>
</mt:If>
</mt:Entries>
</mt:Categories>
<$mt:Var name="timingstop"$>
++++++++++++++++++++++++++++++++++++++++++
<$mt:Var name="timingstart"$>
<mt:Categories>
<mt:SetVarBlock name="cats"><$mt:CategoryLabel$> AND Top Story</mt:SetVarBlock>
<mt:Entries lastn="1" category="$cats">
Hello, <$mt:EntryTitle$>
</mt:Entries>
</mt:Categories>
<$mt:Var name="timingstop"$>
++++++++++++++++++++++++++++++++++++++++++
</mt:Section>
And my output matched in both blocks:
++++++++++++++++++++++++++++++++++++++++++
Hello, Hockey rink gets green light
Hello, Judge strikes down collective bargaining law
Hello, ALRC explores downtown bars
Hello, Judge strikes down collective bargaining law
Hello, Undocumented students: What in-state tuition meant to 1 UW student
Hello, Freezing for a good cause
Hello, Dems push Walker on health care plan
Hello, Student Council takes up WISPIRG legislation
Hello, Possible benefits, drawbacks for voter ID bill on UW campus
Hello, Rally stirs up crowd to reclaim Wis.
Hello, Major winter storm sweeps through Madison
Hello, Photo: Graduation, Class of 2011
Hello, Obama to visit Madison Monday
Hello, ASM preps to take on final MCSC appeal
Hello, Obama to visit Madison Monday
Hello, Republican leadership appoints Johnson to 3 major committees
Hello, Jamie Thomson wins global award for embryonic research
Hello, Task force to recommend new boards
Hello, Faculty weigh HR redesign plan
Hello, Rally stirs up crowd to reclaim Wis.
This code block completed in 18 seconds.
++++++++++++++++++++++++++++++++++++++++++
Hello, Hockey rink gets green light
Hello, Judge strikes down collective bargaining law
Hello, ALRC explores downtown bars
Hello, Judge strikes down collective bargaining law
Hello, Undocumented students: What in-state tuition meant to 1 UW student
Hello, Freezing for a good cause
Hello, Dems push Walker on health care plan
Hello, Student Council takes up WISPIRG legislation
Hello, Possible benefits, drawbacks for voter ID bill on UW campus
Hello, Rally stirs up crowd to reclaim Wis.
Hello, Major winter storm sweeps through Madison
Hello, Photo: Graduation, Class of 2011
Hello, Obama to visit Madison Monday
Hello, ASM preps to take on final MCSC appeal
Hello, Obama to visit Madison Monday
Hello, Republican leadership appoints Johnson to 3 major committees
Hello, Jamie Thomson wins global award for embryonic research
Hello, Task force to recommend new boards
Hello, Faculty weigh HR redesign plan
Hello, Rally stirs up crowd to reclaim Wis.
This code block completed in 12 seconds.
++++++++++++++++++++++++++++++++++++++++++
Note, on this install, the second chunk ran about a third faster than the first one. In order to compare to your 152 second value, which is ten times what it took me with 20 categories and 15,000 entries, I'd need to know more about how many categories and entries you have.