How efficient is op_prg_list_access or prg_list_access? Can I see a profiling report on the time it takes to execute this OPNET Kernel Procedure?

Categories:
Solution Number:
S20618
Last Modified:
2013-08-20
Issue

How efficient is op_prg_list_access or prg_list_access? Can I see a profiling report on the time it takes to execute this OPNET Kernel Procedure?

Solution

Accessing an element of a List variable is performed using the op_prg_list_access() Kernel Procedure (or equivalently using the prg_list_access function). The arguments of the KP are the List to use and the position of the element to access.The list structure maintains 3 pointers into a list: head, tail, and last position accessed. When you use op_prg_list_access (), it first determineswhich of these points the element you are looking for is closest to in the list and then traverses the list either forwards or backwards from that known position to the requested element. Each list element maintains a next and prev pointer to the next or previous list element.In addition, there is also some very small overhead involved in performing some validity checks on the list and the requested element index. If you are using op_prg_list_access to iterate sequentially through a list starting at the end or begining, each op_prg_list_access call will only have to traverse a single list element. Using Big O notation, each op_prg_list_access call in this case is O (1) (order constant). Example:/* Overall, this loop is Order (N) because we do *//* Order (1) operations N times. */for (i = 0; i < list_size; i++) { /* the list access here is Order (1) because it is sequential. */ op_prg_list_acess (list_ptr, i); }If instead you use op_prg_list_access to access elements randomly (ex: first access the 50th element, then the 121st element), in the worst case this would O (N) (order N), where N is the number of elements in the list. Note, however, that the list Kernel Procedures use techinques to give more efficient results in the non-worst case.You can see a profile report of the time it takes to execute any OPNET Kernel Procedure (KP) using OPNET's built in profiling capabilities. Note that the time to execute many KPs, including op_prg_list_access, will vary depending on how you are using it. For more information on profiling, search in the online FAQs for profiling.

Environment

DES Kernel->Other,DES Kernel->Process Modeling/Coding

Attachments
NOTICE: Riverbed® product names have changed. Please refer to the Product List for a complete list of product names.
Can't find an answer? Create a case