ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Здравейте,


office@cadcamcae.bg

www.soft.cadcamcae.bg - Софтуерни решения за машиностроене;

www.forum.cadcamcae.bg - Форум;

www.blog.cadcamcae.bg - Блог;

http://e-shop.cadcamcae.bg - Електронен CAD магазин;

http://www.facebook.com/cad.digest

http://twitter.com/cadcamcae

3D инженерни мишки;

Поздрави

ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения

ФОРУМ: Част от проекта на списание CAD ДАЙДЖЕСТ - www.cadcamcae.bg;

CAD ДАЙДЖЕСТ . Едно онлайн издание за CAD/CAM/CAE технологии и машиностроене
 

ИндексИндекс  PortalPortal  CalendarCalendar  GalleryGallery  Въпроси/ОтговориВъпроси/Отговори  ТърсенеТърсене  ПотребителиПотребители  Потребителски групиПотребителски групи  Регистрирайте сеРегистрирайте се  ВходВход  
Вход
Потребител:
Парола:
Искам да влизам автоматично с всяко посещение: 
:: Забравих си паролата!
Social bookmarking
Social bookmarking Digg  Social bookmarking Delicious  Social bookmarking Reddit  Social bookmarking Stumbleupon  Social bookmarking Slashdot  Social bookmarking Furl  Social bookmarking Yahoo  Social bookmarking Google  Social bookmarking Blinklist  Social bookmarking Blogmarks  Social bookmarking Technorati  

Bookmark and share the address of ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения on your social bookmarking website
Новини от twitter.
Latest topics
Търсене
 
 

Display results as :
 
Rechercher Advanced Search
Споделете с приятел.
Споделете форума В,,, с,,,в,,,е,,,т,,,а,,, н,,,а,,, CAD/CAM/CAE/PLM i Вашия форум за социално споделянеBookmark and Share
Навигация.
 Portal
 Индекс
 Потребители
 Профил
 Въпроси/Отговори
 Търсене
Декември 2016
НедПонВтоСряЧетПетСъб
    123
45678910
11121314151617
18192021222324
25262728293031
CalendarCalendar

Share | 
 

 Оптимизиране на работата с WebLink

Предишната тема Следващата тема Go down 
АвторСъобщение
Admin
Admin


Male Брой мнения : 795
Местожителство : София, България
Job/hobbies : CAD/CAM специалист
Reputation : 3
Points : 5307
Registration date : 27.03.2008

ПисанеЗаглавие: Оптимизиране на работата с WebLink   Вто 13 Май - 14:57:01

While performance testing a processing intensive WebLink application in Pro/Engineer, I came across something surprising. Use of the PTC supplied pfcCreate() function inside a loop made the application significantly slower.

The bigger the loop, the slower the application. For a small loop, the user probably wouldn't notice, but it is very noticeable when recursively processing 10,000+ part assemblies.

Here's what I was using that could be very slow:



for (int i=0; i<array.Count; i++) { obj = pfcCreate("pfcBlahBlahBlah"); // do something here with 'obj'}




I came to the conclusion that getting these objects from the COM server (on windows) was an expensive operation. Minimizing its use seemed to be a very good idea. My first though was to simply pull pfcCreate() out of the loop, which made it much faster. Problem solved!

Faster code:


obj = pfcCreate("pfcBlahBlahBlah");for (int i=0; i<array.Count; i++) { // do something here with 'obj'}





Well, not quite.

The problem is that that chunk of code is used in some other loop, which could be used in some other loop, possibly in some other function, and so on. It was just not enough to rewrite the code in that way. Something else had to be done to eliminate that performance hit.

When it occurred to me that pfcCreate() always returned class objects - the same every time - then I had my answer. Rewrite pfcCreate() and enable caching of the returned objects.

Now, instead of hitting the COM server for every request, the function first performs a lookup of the class object in a global array (creating it if necessary). If the class object has previously been requested, it will be found in the global array, and that object will be returned. If it is not found, the class object is obtained from the COM server, stored in the global array, and then returned to the caller.

In addition to being more efficient when getting WebLink class objects, I now can write my code any way I want putting pfcCreate() inside or outside of the loop, no performance hit either way.


Here is the modified pfcCreate() that I use in my applications:



function pfcCreate (className) { if (!pfcIsWindows()) netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if (className.match(/^M?pfc/)) { // Check global object cache first, then return that object // try { if (className in global_class_cache) { return global_class_cache[className]; } } catch (e) { // Probably no global_class_cache yet global_class_cache = new Object(); } } // Not in global object cache, create object var obj = null; if (pfcIsWindows()) { obj = new ActiveXObject("pfc."+className); } else { obj = Components.classes ["@ptc.com/pfc/" + className + ";1"].createInstance(); } // Return created object // if (className.match(/^M?pfc/)) { global_class_cache[className] = obj; } return obj;}
Върнете се в началото Go down
Вижте профила на потребителя http://cadcamcae-bg.top-forum.net
 
Оптимизиране на работата с WebLink
Предишната тема Следващата тема Върнете се в началото 
Страница 1 от 1

Permissions in this forum:Не Можете да отговаряте на темите
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения :: PTC CREO 3.0: СОФТУЕР ЗА МАШИНОСТРОЕНЕ :: CREO 3.0: Моделиер от висок клас (бивш Pro/ENGINEER Wildfire)-
Идете на: