ФОРУМ за света на 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 магазин;

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

http://twitter.com/cadcamcae

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

Поздрави
ФОРУМ за света на 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 магазин;

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

http://twitter.com/cadcamcae

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

Поздрави
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Would you like to react to this message? Create an account in a few clicks or log in to continue.

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

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

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

ИндексИндекс  PortalPortal  ГалерияГалерия  ТърсенеТърсене  Последни снимкиПоследни снимки  Регистрирайте сеРегистрирайте се  ВходВход  
Вход
Потребителско име:
Парола:
Искам да влизам автоматично с всяко посещение: 
:: Забравих си паролата!
Social bookmarking
Social bookmarking reddit      

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
 Индекс
 Потребители
 Профил
 Въпроси/Отговори
 Търсене
Април 2024
НедПонВтоСряЧетПетСъб
 123456
78910111213
14151617181920
21222324252627
282930    
КалендарКалендар

 

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

Go down 
АвторСъобщение
Admin
Admin
Admin


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

Оптимизиране на работата с WebLink Empty
ПисанеЗаглавие: Оптимизиране на работата с WebLink   Оптимизиране на работата с WebLink Icon_minitimeВто 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
https://cadcamcae-bg.bulgarianforum.net
 
Оптимизиране на работата с WebLink
Върнете се в началото 
Страница 1 от 1
 Similar topics
-
» The Classic First Example Program for WebLink

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