Источник:
http://axforum.info/forums/blog.php?b=8176
==============
X++:
static void SimpleWatch(Args _args) { DEV_Global::startWatch(1); DEV_Global::startWatch(2); sleep(100); DEV_Global::stopWatch(
'Watch 1', 1); sleep(300); DEV_Global::stopWatch(
'Watch 2', 2); }
Код:
Watch 1: 00:00:00.1007452 Watch 2: 00:00:00.4087249
X++:
static public server void startWatch(
int _idx = 1) { System.Diagnostics.Stopwatch watch; watch =
new System.Diagnostics.Stopwatch(); watch.Start();
if (appl.globalCache().isSet(
identifierStr(Stopwatch), _idx)) { appl.globalCache().remove(
identifierStr(Stopwatch), _idx); info(
'Old watch has been reset.'); } appl.globalCache().set(
identifierStr(Stopwatch), _idx, watch); }
X++:
static public server str stopWatch( TempStr _txt =
'Elapsed time',
int _idx = 1, boolean _skipInfo =
false) { System.Diagnostics.Stopwatch watch; System.TimeSpan elapsed;
str ret;
if (appl.globalCache().isSet(
identifierStr(Stopwatch), _idx)) { watch = appl.globalCache().get(
identifierStr(Stopwatch), _idx); appl.globalCache().remove(
identifierStr(Stopwatch), _idx); }
if (watch && watch.get_IsRunning()) { watch.Stop(); elapsed = watch.get_Elapsed(); ret = CLRInterop::getAnyTypeForObject(elapsed.ToString());
if (!_skipInfo) { info(strFmt(
'%1: %2', _txt, ret)); } }
else { info(
'Watch is not running.'); }
return ret; }
Источник:
http://axforum.info/forums/blog.php?b=8176