24 #ifndef __TPIE_SYSINFO__
25 #define __TPIE_SYSINFO__
29 #include <boost/asio/ip/host_name.hpp>
30 #include <boost/date_time/posix_time/posix_time.hpp>
52 : m_platform(calc_platform())
53 , m_hostname(calc_hostname())
54 , m_blocksize(calc_blocksize())
76 inline std::string
platform()
const {
return m_platform; }
81 inline std::string
hostname()
const {
return m_hostname; }
86 inline std::string
blocksize()
const {
return m_blocksize; }
92 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
93 return to_simple_string(now);
121 template <
typename V>
122 inline std::string
custominfo(std::string key,
const V & value) {
123 std::stringstream builder;
124 if (key !=
"") key +=
':';
125 builder.flags(std::ios::left);
126 builder << std::setw(16) << key << value;
127 return builder.str();
133 template <
typename V>
134 inline void printinfo(std::string key,
const V & value) {
135 std::cout <<
custominfo(key, value) << std::endl;
138 static inline memory_size_type blocksize_bytes() {
143 static const char * m_commit;
144 static const char * m_refspec;
145 const std::string m_platform;
146 const std::string m_hostname;
147 const std::string m_blocksize;
149 static inline std::string calc_platform() {
156 p << (8*
sizeof(size_t)) <<
"-bit";
160 static inline std::string calc_hostname() {
162 return boost::asio::ip::host_name();
163 }
catch (boost::system::system_error & e) {
164 log_debug() <<
"boost::system::system_error thrown while getting hostname. e.what() == " << e.what() << std::endl;
169 static inline std::string calc_blocksize() {
170 std::stringstream ss;
171 ss << blocksize_bytes() / 1024
181 inline std::ostream & operator<<(std::ostream & s,
const sysinfo & info) {
183 <<
"Hostname: " << info.
hostname() <<
'\n'
184 <<
"Platform: " << info.
platform() <<
'\n'
185 <<
"Git branch: " << info.
refspec() <<
'\n'
186 <<
"Git commit: " << info.
commit() <<
'\n'
187 <<
"Local time: " << info.
localtime() <<
'\n'
188 <<
"Block size: " << info.
blocksize() <<
'\n'
190 #ifdef TPIE_PARALLEL_SORT
197 #ifdef TPIE_HAS_SNAPPY
208 #endif // __TPIE_SYSINFO__
memory_size_type get_block_size()
Get the TPIE block size.
std::string refspec() const
Git refspec.
void printinfo(std::string key, const V &value)
Print custom info to std::cout.
Streams that support substreams.
Class providing system and platform info.
Logging functionality and log_level codes for different priorities of log messages.
std::string commit() const
Git commit hash.
std::string blocksize() const
Block size used by tpie::ami::stream.
std::string custominfo(std::string key, const V &value)
Helper function to make a custom key-value line.
std::string hostname() const
System hostname as reported by Boost ASIO.
logstream & log_debug()
Return logstream for writing debug log messages.
std::string localtime() const
Local date and time in a human-readable format.
const char * git_commit
The Git commit hash (40 hexadecimal characters) that TPIE was built from.
const char * git_refspec
The Git refspec that TPIE was built from.
std::string platform() const
Platform description.
sysinfo()
Default constructor.