Created
May 16, 2022 23:50
-
-
Save gofman/c08e58f15105d60b4576c9ae25bcec9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1e70fbfeb4949dec62dfb1d06e4f830b69d09f03 Mon Sep 17 00:00:00 2001 | |
From: Paul Gofman <pgofman@codeweavers.com> | |
Date: Fri, 6 May 2022 14:39:27 -0500 | |
Subject: [PATCH] iphlpapi/tests: (temp) Test GetAdaptersInfo() performance. | |
--- | |
dlls/iphlpapi/tests/iphlpapi.c | 42 ++++++++++++++++++++++++++++++---- | |
1 file changed, 38 insertions(+), 4 deletions(-) | |
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c | |
index c40ae3989c6..a9aa9b064e2 100644 | |
--- a/dlls/iphlpapi/tests/iphlpapi.c | |
+++ b/dlls/iphlpapi/tests/iphlpapi.c | |
@@ -1380,15 +1380,31 @@ static void testGetInterfaceInfo(void) | |
} | |
} | |
+static LARGE_INTEGER perf_freq; | |
+ | |
+static double curr_time_ms(void) | |
+{ | |
+ LARGE_INTEGER c; | |
+ | |
+ QueryPerformanceCounter(&c); | |
+ return 1000.0 * c.QuadPart / perf_freq.QuadPart; | |
+} | |
+ | |
static void testGetAdaptersInfo(void) | |
{ | |
+ static const int test_count = 500; | |
+ int i; | |
+ | |
IP_ADAPTER_INFO *ptr, *buf; | |
NET_LUID luid; | |
GUID guid; | |
char name[ARRAY_SIZE(ptr->AdapterName)]; | |
DWORD err; | |
- ULONG len = 0; | |
+ ULONG len = 0, len2; | |
MIB_IFROW row; | |
+ double t1, t2; | |
+ | |
+ QueryPerformanceFrequency(&perf_freq); | |
err = GetAdaptersInfo( NULL, NULL ); | |
ok( err == ERROR_INVALID_PARAMETER, "got %ld\n", err ); | |
@@ -1399,6 +1415,19 @@ static void testGetAdaptersInfo(void) | |
buf = malloc( len ); | |
err = GetAdaptersInfo( buf, &len ); | |
ok( !err, "got %ld\n", err ); | |
+ | |
+ t1 = curr_time_ms(); | |
+ for (i = 0; i < test_count; ++i) | |
+ { | |
+ len2 = 0; | |
+ err = GetAdaptersInfo( NULL, &len2); | |
+ ok(err == ERROR_BUFFER_OVERFLOW && len == len2, "Unexpected err %ld, len2 %ld.\n", err, len2); | |
+ err = GetAdaptersInfo( buf, &len ); | |
+ ok( !err, "got %ld\n", err ); | |
+ t2 = curr_time_ms(); | |
+ } | |
+ trace("time1 %.1lf.\n", (t2 - t1) / test_count); | |
+ | |
ptr = buf; | |
while (ptr) | |
{ | |
@@ -1465,8 +1494,10 @@ IpRenewAddress | |
*/ | |
static DWORD CALLBACK testWin98Functions(void *p) | |
{ | |
- testGetInterfaceInfo(); | |
+ if (0) | |
+ testGetInterfaceInfo(); | |
testGetAdaptersInfo(); | |
+return 0; | |
testGetNetworkParams(); | |
return 0; | |
} | |
@@ -2683,13 +2714,16 @@ START_TEST(iphlpapi) | |
if (hLibrary) { | |
HANDLE thread; | |
+if(0){ | |
testWin98OnlyFunctions(); | |
testWinNT4Functions(); | |
+} | |
/* run testGetXXXX in two threads at once to make sure we don't crash in that case */ | |
- thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL); | |
+// thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL); | |
testWin98Functions(NULL); | |
- WaitForSingleObject(thread, INFINITE); | |
+// WaitForSingleObject(thread, INFINITE); | |
+return; | |
testWin2KFunctions(); | |
test_GetAdaptersAddresses(); | |
-- | |
2.36.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment