With ETW, like : https://github.com/GameTechDev/PresentMon
(or by hooking IDXGISwapChain::Present with a DLL, more complicated. I had done it with MS Detours a long time ago, but can be done with other API Hooking Libraries, like MinHook, EasyHook,...)