From 412d47eacf9b2da4bfe0d8299f8572c4b2e4ce50 Mon Sep 17 00:00:00 2001 From: Lari Nieminen Date: Thu, 28 Jun 2007 22:11:42 +0000 Subject: [PATCH] Added a macro for conveniently timing arbitrary WML actions. --- data/core/macros/utils.cfg | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/data/core/macros/utils.cfg b/data/core/macros/utils.cfg index 178033443fc..e1a18147c50 100644 --- a/data/core/macros/utils.cfg +++ b/data/core/macros/utils.cfg @@ -432,4 +432,30 @@ name=prestart #define MENU_IMG_TXT2 IMG TXT1 TXT2 "&"+{IMG}+"="+{TXT1}+"="+{TXT2}#enddef +#define TIME_ACTIONS CONTENTS +# Measure (in milliseconds) the time arbitrary event WML takes to execute. +# Afterwards, the time the enclosed WML took to execute is found in the variable +# $timed_actions_ms. +# +# Example: +#! [event] +#! name=start +#! +#! {TIME_ACTIONS ( +#! {MODIFY_UNIT race=orc user_description ( _ "Azir")} +#! )} +#! +#! {DEBUG_MSG "Renaming all orcs to Azir took $timed_actions_ms|ms."} +#! [/event] + {VARIABLE_OP TIME_ACTIONS_time_begin time stamp} + {CONTENTS} + + {VARIABLE_OP TIME_ACTIONS_time_end time stamp} + + {VARIABLE timed_actions_ms $TIME_ACTIONS_time_end} + {VARIABLE_OP timed_actions_ms add "-$TIME_ACTIONS_time_begin"} + + {CLEAR_VARIABLE TIME_ACTIONS_time_begin} + {CLEAR_VARIABLE TIME_ACTIONS_time_end} +#enddef \ No newline at end of file