New Posts New Posts RSS Feed: Asynchronous Performance Question
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Asynchronous Performance Question

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Asynchronous Performance Question
    Posted: 19-Nov-2010 at 10:07am
Is there any difference, performance wise between using lambda expressions to perform the callback in the Get data method versus an actual callback method being used?
 
Bill
 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2010 at 5:23pm
Hi Bill;

I used the following code to time it out.

public void TimingLambdaExpressionVsCallback() {

      _lambdaStopwatch.Start();
      var lambdaQuery = _mgr.Employees;
      lambdaQuery.ExecuteAsync(e => {
        var employees1 = new ObservableCollection<Employee>();
        e.Results.ForEach(employees1.Add);
        _lambdaStopwatch.Stop();
        Output += "_lambdaStopwatch = " + _lambdaStopwatch.ElapsedMilliseconds + Environment.NewLine;
      });

      _callbackStopwatch.Start();
      var callbackQuery = _mgr.Employees.ExecuteAsync();
      callbackQuery.Completed += callbackQuery_Completed;
    }

    void callbackQuery_Completed(object sender, EntityQueriedEventArgs<Employee> e) {
      var employees2 = new ObservableCollection<Employee>();
      e.Results.ForEach(employees2.Add);
      _callbackStopwatch.Stop();
      Output += "_callbackStopwatch = " + _callbackStopwatch.ElapsedMilliseconds + Environment.NewLine;
    }

_lambdaStopwatch would take between 3ms and 23ms longer than _callbackStopwatch.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down