AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.05.2009, 20:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
SysDictCoder: X++ method call performance
Источник: http://sysdictcoder.com/blog/x-method-call-performance/
==============

Microsoft’s recommendations for performance optimizations are interesting:
  • Calls between tiers (client/server) are slow.
  • Method calls are expensive. Try to reduce the number of calls. For example, don’t call the same method several times if you can store a value from the method and instead use that value.
These statements are probably true but as with all good advice it is important to know the context in which it makes sense. How slow is slow and how expensive is expensive? And should you worry about it? Let’s find out.

Test cases

In X++ there are different kinds of methods and different ways to call them. There are some interesting cases I can think of right away.
  • Static versus instance methods
  • Staying on the same tier versus calling methods across tiers
  • Calling a method on an object of a supertype (Object) instead of the exact subtype
  • Calling a method through reflection (SysDict* classes)
Test setup

Methods calls may be slow, but they’re certainly not slow enough to accurately measure the time of a single call. Repeating the exact same call a large number of times should average out any measurement errors.

The timing code is basically this:

<div class="wp_syntax"><div class="code"> timer.start(1); for (i=1; i
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Старый 04.05.2009, 22:13   #2  
Logger is offline
Logger
Участник
Лучший по профессии 2015
Лучший по профессии 2014
 
3,875 / 3123 (112) ++++++++++
Регистрация: 12.10.2004
Адрес: Москва
Записей в блоге: 2
Цитата:
Сообщение от Blog bot Посмотреть сообщение
For example, don’t call the same method several times if you can store a value from the method and instead use that value.
Спорное утверждение. В большинстве случаев выигрыш несуществен, зато читаемость кода ухудшается гарантированно. В пособиях по рефакторингу тоже не рекомендуют злоупотреблять локальными переменными.
Теги
x++

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Microsoft Dynamics CRM Team Blog: Performance Testing using DbPopulator Blog bot Dynamics CRM: Blogs 0 21.02.2009 06:28
error at call static method for CLRobject axstart DAX in English 4 25.09.2008 23:23
Как понять что вызывает исключение Invalid Method Call Jab Straight DAX: Программирование 0 17.12.2007 23:23
axaptapedia: Display method Blog bot DAX Blogs 0 29.08.2007 16:30
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:03.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.