I have a function which i use for stress testing and i want to stress test multiple functions. The function that i am stress testing here is GetParameters(reportUri, SessionContext);
How can i add a helper function in which i can pass a parameter such as an action body or a delegate (this is good but i have multiple functions with different paramters). and it executes all the steps by just replacing this.RemoteReportingServiceFactory.CreateReportParameterProvider().GetParameters(reportUri, SessionContext);
dynamically. The entire function body is going to be same except for above mentioned line
public void GetParameters()
{
for (int i = 0; i < 100; i++)
{
Log.Message(TraceEventType.Information, "Start of {0} sequential iteration with 5 parallel stress runs".InvariantFormat(i));
Parallel.For(0, 2, parameterIteration =>
{
Log.Message(TraceEventType.Information, "Stress run count : {0}".InvariantFormat(parameterIteration + 1));
string reportUrl = TeamFoundationTestConfig.TeamFoundationReportPath("TaskGroupStatus");
ReportUri reportUri = ReportUri.Create(reportUrl);
Log.Message(TraceEventType.Information, "ReportUri = {0}".InvariantFormat(reportUri.UriString));
IList<Parameter> parameters = this.RemoteReportingServiceFactory.CreateReportParameterProvider().GetParameters(reportUri, SessionContext);
});
}
}
Let me know if am not clear enough. I can edit my questions as per requests
How about changeing the method to something like
public void GetParameters(Func<ReportUri, SessionContext, IList<Parameter>> returnStuff)
{
for (int i = 0; i < 100; i++)
{
Log.Message(TraceEventType.Information, "Start of {0} sequential iteration with 5 parallel stress runs".InvariantFormat(i));
Parallel.For(0, 2, parameterIteration =>
{
Log.Message(TraceEventType.Information, "Stress run count : {0}".InvariantFormat(parameterIteration + 1));
string reportUrl = TeamFoundationTestConfig.TeamFoundationReportPath("TaskGroupStatus");
ReportUri reportUri = ReportUri.Create(reportUrl);
Log.Message(TraceEventType.Information, "ReportUri = {0}".InvariantFormat(reportUri.UriString));
IList<Parameter> parameters = returnStuff(reportUri, SessionContext);
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.