LDAP에 로그인 스트레스 테스트를 시뮬레이트하고 싶습니다. 여러 요청에서 동시에 LDAP에 대한 인증 요청을 보냅니다.로그인 스트레스 테스트
static void Main(string[] args)
{
string a = "", b = "", c = "", d = "",
e = "", f = "", g = "", h = "", i = "", j = "", k = "";
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var startTime = DateTime.Now.ToString("hh:mm:ss.fff tt");
Parallel.Invoke
(
() => a = LdsConnection.Auth("username", "password", true),
() => b = LdsConnection.Auth("username", "password", true),
() => c = LdsConnection.Auth("username", "password", true),
() => d = LdsConnection.Auth("username", "password", true),
() => e = LdsConnection.Auth("username", "password", true),
() => f = LdsConnection.Auth("username", "password", true),
() => g = LdsConnection.Auth("username", "password", true),
() => h = LdsConnection.Auth("username", "password", true),
() => i = LdsConnection.Auth("username", "password", true),
() => j = LdsConnection.Auth("username", "password", true),
() => k = LdsConnection.Auth("username", "password", true)
);
stopwatch.Stop();
var endTime = DateTime.Now.ToString("hh:mm:ss.fff tt");
Console.WriteLine(a + "\n");
Console.WriteLine(b + "\n");
Console.WriteLine(c + "\n");
Console.WriteLine(d + "\n");
Console.WriteLine(e + "\n");
Console.WriteLine(f + "\n");
Console.WriteLine(g + "\n");
Console.WriteLine(h + "\n");
Console.WriteLine(j + "\n");
Console.WriteLine(k + "\n");
// Total run time
Console.WriteLine("Started:{0}\nEnded: {1}\nElapsed: {2}",
startTime, endTime, stopwatch.Elapsed);
Console.ReadKey();
}
public static string Auth (string username, string password, bool fullDn)
{
var url = GenerateUrl(fullDn);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var startTime = DateTime.Now.ToString("hh:mm:ss.fff tt");
try
{
Connect(username, password, url);
stopwatch.Stop();
var elaps = stopwatch.Elapsed.ToString();
var endTime = DateTime.Now.ToString("hh:mm:ss.fff tt");
return string.Format("Started:{0}\nEnded: {1}\nElapsed: {2}",
startTime, endTime, elaps);
}
catch (Exception exception)
{
return "Error";
}
}
문제점은 다음과 같습니다 :
- 가 어떻게이 문제를 자동화 할 수 있습니다 예를 들어, 동일한 기능의 다중를 호출하는 대신 호출의 수를 나타냅니다 매개 변수 나는 다음과 같이 썼다 사용자 이름과 암호가 모든 기능에 대해 동일하기 때문에 수동으로 시간을?
- 모든 호출이 동시에 인증을 요청하는지 잘 모르겠습니다.
어떤 팁을 주시겠습니까?
감사합니다. John C, 저는 어떻게하면 루프 수를 제어 할 수 있는지 보지 못합니다. – Maro
'ForEach()'의 첫 번째 매개 변수는 배열로, 동적으로 생성 할 수 있으므로 한 요청에서 필요한만큼 빠르게 확장 할 수 있습니다. –
+1 고맙습니다. – Maro