24 #ifndef __TPIE_SYSINFO__
25 #define __TPIE_SYSINFO__
27 #include <tpie/tpie_export.h>
30 #include <boost/asio/ip/host_name.hpp>
31 #include <boost/date_time/posix_time/posix_time.hpp>
53 : m_platform(calc_platform())
54 , m_hostname(calc_hostname())
55 , m_blocksize(calc_blocksize())
77 inline std::string
platform()
const {
return m_platform; }
82 inline std::string
hostname()
const {
return m_hostname; }
87 inline std::string
blocksize()
const {
return m_blocksize; }
93 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
94 return to_simple_string(now);
122 template <
typename V>
123 inline std::string
custominfo(std::string key,
const V & value) {
124 std::stringstream builder;
125 if (key !=
"") key +=
':';
126 builder.flags(std::ios::left);
127 builder << std::setw(16) << key << value;
128 return builder.str();
134 template <
typename V>
135 inline void printinfo(std::string key,
const V & value) {
136 std::cout <<
custominfo(key, value) << std::endl;
139 static inline memory_size_type blocksize_bytes() {
144 static const char * m_commit;
145 static const char * m_refspec;
146 const std::string m_platform;
147 const std::string m_hostname;
148 const std::string m_blocksize;
150 static inline std::string calc_platform() {
157 p << (8*
sizeof(size_t)) <<
"-bit";
161 static inline std::string calc_hostname() {
163 return boost::asio::ip::host_name();
164 }
catch (boost::system::system_error & e) {
165 log_debug() <<
"boost::system::system_error thrown while getting hostname. e.what() == " << e.what() << std::endl;
170 static inline std::string calc_blocksize() {
171 std::stringstream ss;
172 ss << blocksize_bytes() / 1024
182 inline std::ostream & operator<<(std::ostream & s,
const sysinfo & info) {
184 <<
"Hostname: " << info.
hostname() <<
'\n'
185 <<
"Platform: " << info.
platform() <<
'\n'
186 <<
"Git branch: " << info.
refspec() <<
'\n'
187 <<
"Git commit: " << info.
commit() <<
'\n'
188 <<
"Local time: " << info.
localtime() <<
'\n'
189 <<
"Block size: " << info.
blocksize() <<
'\n'
191 #ifdef TPIE_PARALLEL_SORT
198 #ifdef TPIE_HAS_SNAPPY
209 #endif // __TPIE_SYSINFO__