他人の空似自作物置場

CallerCheck_SimExec.zip/Tools/Measure/main.cpp


#include <iostream>

#include <Windows.h>

#include <boost/format.hpp>
#include <boost/range/irange.hpp>

#pragma comment(lib, "OneCore_downlevel.lib")

void run() {
   const HMODULE module = ::GetModuleHandleA("ntdll.dll");
   const unsigned int start = ::timeGetTime();
   for (const unsigned int i : boost::irange(0, 1000000)) {
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
      ::GetProcAddress(module, "LdrLoadDll");
   }
   const unsigned int end = ::timeGetTime();
   const unsigned int result = end - start;
   std::cout << boost::format("%dms\n") % result;
}

int main() {
   run();
   run();
   std::cin.get();
   return 0;
}