How does this test run the queries, are they delegates? What is Action<int>?
http://code.google.com/p/dapper-dot-net/source/browse/PerformanceTests.cs
Confused, PerformanceTest.Run initializes the list by adding test objects.
How does it actually run the query?
I'm guessing it is the line:
for (int i = 1; i <= iterations; i++)
{
foreach (var test in this.OrderBy(ignore => rand.Next()))
{
test.Watch.Start();
test.Iteration(i);
test.Watch.Stop();
开发者_JAVA百科 }
}
test.iteration(i);
But how? Is this a delegate?
Yes, Action type is the key here. Action<T> is a built-in delegate type that has no return value and (in this case) takes one parameter of type T. Iteration is the property of type Action<int> where the test action is stored in Test object, and () operator just invokes the method with i parameter.
Yes, Action<int> is a delegate that accepts an integer as an argument (in this case, the iteration number).
加载中,请稍侯......
精彩评论