[Mono-dev] Performance of Invoke

Tim Michals tcmichals at msn.com
Tue Jun 13 23:06:44 EDT 2006


I've tested on .NET the performance of invoke compared to Delegate, Delegate 
is several orders of magnitude faster.  The problem I'm having is creating a 
delegate with the proper type, Delegate.CreateDelegate requires the delegate 
type to be defined.  But the base library only knows the base type not the 
class defined in the user code
For example...(This is a very basic pseudo code)   Looking for better 
perfomance then using Invoke..I read some methods of creating LCG but is 
that the only way?

//defined in class library
class fsmEvent{}
class fsm
{
    //events can be posted to the event queue and read from the dispatch 
loop from a thread...
    public Queue<fsmEvent>  QueueEvent;

 public void dispatchEvent()
 {
  .....
        fsmEv = Queue.dequeue();
      Type t= userFsm.GetType();
      MethodInfo mFsmEvent = t.GetMethod(  ... based on fsmEv type, match 
the parameter list)
    // invoke proper method
      mFsmEvent.Invoke(userFsm,new object[]{ fsmLoop.fsmEventList[0]});
   // Want to replace this is some type of Delegate for performance...

     }
}

// define in user library
class userFsmEvent : fsmEvent{}
class fsmTimerEvent : fsmEvent{}

class fsmUser
{
    public void hander1(fsmEvent ev){}
    public void handler2(fsmTimerEvent ev){}
    public void hander3(userFsmEvent ev){}

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060613/eac78905/attachment.html 


More information about the Mono-devel-list mailing list