Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <vector>
- #include <chrono>
- #include <numeric>
- int main()
- {
- std::vector<unsigned long long> times(40);
- HDC hdcScreen = ::GetDC(HWND_DESKTOP);
- HDC hdcShot = ::CreateCompatibleDC(hdcScreen);
- int cx = GetDeviceCaps(hdcScreen, HORZRES);
- int cy = GetDeviceCaps(hdcScreen, VERTRES);
- HGDIOBJ hbmpShot = ::CreateCompatibleBitmap(hdcScreen, cx, cy);
- hbmpShot = SelectObject(hdcShot, hbmpShot);
- for( size_t i = times.size(); i--; ) {
- auto start = std::chrono::high_resolution_clock::now();
- ::BitBlt(hdcShot, 0, 0, cx, cy, hdcScreen, 0, 0, SRCCOPY);
- auto finish = std::chrono::high_resolution_clock::now();
- times[i] = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count();
- }
- ::ReleaseDC(HWND_DESKTOP, hdcScreen);
- hbmpShot = SelectObject(hdcShot, hbmpShot);
- ::DeleteObject(hbmpShot);
- ::DeleteDC(hdcShot);
- printf("Time: %f\n", double(std::accumulate(times.begin(), times.end(), (unsigned long long)0)) / times.size());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement