Test boost::chrono::process_cpu_clock
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,9 +4,11 @@
|
||||
*.sdf
|
||||
*.suo
|
||||
*.ncb
|
||||
*.pdb
|
||||
*.lib
|
||||
*.dll
|
||||
*.exe
|
||||
*.manifest
|
||||
*.a
|
||||
*.so
|
||||
*.swp
|
||||
|
||||
27
_setup_vc11_env.bat
Normal file
27
_setup_vc11_env.bat
Normal file
@@ -0,0 +1,27 @@
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64
|
||||
|
||||
set BOOST=C:\Users\Vahagnk\src\boost_1_53_0
|
||||
set BOOST_INCLUDE=%BOOST%
|
||||
set BOOST_LIB=%BOOST%\stage\win64_vc12\lib
|
||||
|
||||
set GTEST=C:\Users\Vahagnk\src\gtest-1.6.0
|
||||
set GTEST_INCLUDE=%GTEST%\include
|
||||
set GTEST_LIB=%GTEST%\build_x64_vc12
|
||||
|
||||
set ZLIB=C:\Users\Vahagnk\src\zlib-1.2.7
|
||||
set ZLIB_INCLUDE=%ZLIB%
|
||||
set ZLIB_LIB=%ZLIB%\build_x64_vc12
|
||||
|
||||
set LIBPNG=C:\Users\Vahagnk\src\libpng-1.5.10
|
||||
set LIBPNG_INCLUDE=%LIBPNG%
|
||||
set LIBPNG_LIB=%LIBPNG%\build_x64_vc10
|
||||
|
||||
set TBB=C:\Users\Vahagnk\src\tbb41_20121003oss
|
||||
set TBB_INCLUDE=%TBB%\include
|
||||
set TBB_LIB=%TBB%\lib\intel64\vc11
|
||||
set TBB_BIN=%TBB%\bin\intel64\vc11
|
||||
|
||||
set CXXFLAGS=/I%BOOST_INCLUDE% /I%TBB_INCLUDE% /I%GTEST_INCLUDE% /I%LIBPNG_INCLUDE% /I%ZLIB_INCLUDE% /D_CRT_SECURE_NO_WARNINGS /D_DEBUG /DWIN32 /MDd /Od /Zi /EHsc
|
||||
set LDFLAGS=/INCREMENTAL:NO /LIBPATH:%BOOST_LIB% /LIBPATH:%TBB_LIB% /DEBUG /MACHINE:X64 /SUBSYSTEM:CONSOLE
|
||||
set PATH=%TBB_BIN%;%TBB_LIB%;%BOOST_LIB%;%PATH%
|
||||
|
||||
36
boost_chrono_process_cpu.cpp
Normal file
36
boost_chrono_process_cpu.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <boost/chrono/process_cpu_clocks.hpp>
|
||||
|
||||
|
||||
int main ( void )
|
||||
{try{
|
||||
|
||||
boost::chrono::process_cpu_clock clock;
|
||||
boost::chrono::process_cpu_clock::time_point b = clock.now();
|
||||
std::this_thread::sleep_for( std::chrono::seconds( 2 ) );
|
||||
boost::chrono::process_cpu_clock::time_point e = clock.now();
|
||||
boost::chrono::process_cpu_clock::duration d = e - b;
|
||||
|
||||
auto times = d.count();
|
||||
std::cout << times.real / 1e+9 << std::endl;
|
||||
std::cout << times.user / 1e+9 << std::endl;
|
||||
std::cout << times.system / 1e+9 << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch ( const std::exception& e )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "unknown exception." << std::endl;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user