Показать сообщение отдельно
Старый 04.02.2013, 02:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
Axilicious:System.Diagnostics.StopWatch
Источник: http://www.ksaelen.be/wordpresses/dy...ics-stopwatch/
==============

I often see code that still uses the WinApi::GetTickCount method to measure an interval of time. And though there is nothing wrong with it, I wanted to show an alternative method : the StopWatch already known in .Net for quite some time.
The sample below show the usage of the stopwatch while I was testing something out with looping all of the tables in the system:
X++:
static void FetchTableNames_ModelElementTables(Args _args)
{
    SysModelElement element;
    SysModelElementType elementType;
    System.Collections.ArrayList tableNames = new System.Collections.ArrayList();
    System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
    int64 elapsed;
    ;
 
    stopWatch.Start();
 
    // The SysModelElementType table contains the element types and we need the recId for the next selection
    select firstonly RecId
    from elementType
    where elementType.Name == 'Table';
 
    // With the recId of the table element type, select all of the elements with that type (hence, select all of the tables)
    while select Name
    from element
    where element.ElementType == elementType.RecId
    {
        tableNames.Add(element.Name);
    }
 
    stopWatch.Stop();
 
    // Get the time it took
    elapsed = stopWatch.get_ElapsedMilliseconds();
 
    info(strFmt("Time taken: %1", elapsed));
}

Источник: http://www.ksaelen.be/wordpresses/dy...ics-stopwatch/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 04.02.2013 в 09:29.