Skip to content

Feature: Add Display Detection & Audio Detection support for Windows platform && Refactor: move systems to use C++ wmi query function, much better performance#2

Merged
kernel-dev merged 26 commits intoMahasvan:mainfrom
kernel-dev:feat/display-detection-win
Jan 10, 2026

Conversation

@kernel-dev
Copy link
Copy Markdown
Collaborator

@kernel-dev kernel-dev commented Jan 9, 2026

This PR implements display detection support for the Windows platform; more specifically:

  • Helper C++ method GetGPUForDisplay(...), GetWmiInfo(...), GetNetworkHardwareInfo(...), GetAudioHardwareInfo(...)
    • Gets compiled to a DLL, inside of src/pysysinfo/interops/win/dll
    • Setuptools now bundles DLLs / libraries from interops/{platform}/dll/*.dll
  • Implements models for Display, DisplayModule and Resolution info
  • Implements fetching various display information through enumerating monitor PROCs and fetching their respective EDIDs
  • __init__.py now loads bundled DLLs for Windows platform properly - example of loading currently included DLL module (this DLL path can be bundled, exact partitioning / structure TBD):
with resources.path("pysysinfo.interops.win.dll", "gpu_helper.dll") as dll_path:
   gpu_helper = ctypes.CDLL(str(dll_path))

gpu_helper.GetGPUForDisplay.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int]
gpu_helper.GetGPUForDisplay.restype = ctypes.c_uint32

...
  • display.py may need some cleaning up, it's very messy at the moment, so that's why this PR is marked as draft for now
    • Also will attempt to implement support for detecting size in inches, aspect ratio & mode (landscape/portrait) COMPLETED
  • Implements Audio Detection support for Windows platform
    • Groups audio devices (microphone, speakers, AMP/DAC, USB device, etc.) by their parent audio controllers (Realtek, NVidia, etc.)
  • Unit tests for Display; improvements to Network UTs

Performance

Tested the performance of fetch_display_info(), on average it takes about ~11ms to fetch display data for 2 displays.
The below logs are pre-network implementation and ACPI/PCI path fetching improvements.

Time for additional details: 0.0002758502960205078
CPU: 0.50830078125 ms
Memory: 6.171630859375 ms
Storage: 39.002685546875 ms
Display: 20.0087890625 ms
Network: 25.7490234375 ms
Audio: 55.676025390625 ms
Graphics: 125.243408203125 ms
Total: 272.35986328125 ms
Reference `main.py` timing code
start_times = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
# CPU, Memory, Storage, Display, Network, Audio, Graphics, Total
end_times = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

start_times[0] = start_times[-1] = time.time() * 1000

hm.fetch_cpu_info()
end_times[0] = start_times[1] = time.time() * 1000

hm.fetch_memory_info()
end_times[1] = start_times[2] = time.time() * 1000

hm.fetch_storage_info()
end_times[2] = start_times[3] = time.time() * 1000

hm.fetch_display_info()
end_times[3] = start_times[4] = time.time() * 1000

hm.fetch_network_info()
end_times[4] = start_times[5] = time.time() * 1000

hm.fetch_audio_info()
end_times[5] = start_times[6] = time.time() * 1000

hm.fetch_graphics_info()
end_times[-2] = end_times[-1] = time.time() * 1000


print("CPU:", end_times[0] - start_times[0], "ms")
print("Memory:", end_times[1] - start_times[1], "ms")
print("Storage:", end_times[2] - start_times[2], "ms")
print("Display:", end_times[3] - start_times[3], "ms")
print("Network:", end_times[4] - start_times[4], "ms")
print("Audio:", end_times[5] - start_times[5], "ms")
print("Graphics:", end_times[-2] - start_times[-2], "ms")
print("Total:", end_times[-1] - start_times[-1], "ms")

@kernel-dev kernel-dev marked this pull request as ready for review January 9, 2026 20:20
@kernel-dev
Copy link
Copy Markdown
Collaborator Author

Below you can see that display UTs have full coverage over the module
image

@kernel-dev kernel-dev changed the title Feature: Add Display Detection support for Windows platform Feature: Add Display Detection support for Windows platform && Refactor: move systems to use C++ wmi query function, much better performance Jan 10, 2026
@kernel-dev
Copy link
Copy Markdown
Collaborator Author

Total time of fetching all (currently implemented) hardware implementation post-optimizations averages anywhere between 200-250ms. Executed using pyinstrument
image

@kernel-dev kernel-dev changed the title Feature: Add Display Detection support for Windows platform && Refactor: move systems to use C++ wmi query function, much better performance Feature: Add Display Detection & Audio Detection support for Windows platform && Refactor: move systems to use C++ wmi query function, much better performance Jan 10, 2026
@kernel-dev kernel-dev merged commit f7cdddd into Mahasvan:main Jan 10, 2026
1 check passed
@kernel-dev kernel-dev deleted the feat/display-detection-win branch January 10, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant