From 63cf599696abce2a4f67ba9d34697c5b804cd1c5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 13 Jan 2013 13:46:04 +0000 Subject: Put CPU info into log, on POSIX at least. --- src/lib/film.cc | 2 ++ src/lib/util.cc | 26 ++++++++++++++++++++++++++ src/lib/util.h | 1 + 3 files changed, 29 insertions(+) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index ad9f65256..f481399a9 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -269,6 +269,8 @@ Film::make_dcp (bool transcode) #else log()->log ("libdcp built in optimised mode."); #endif + pair const c = cpu_info (); + log()->log (String::compose ("CPU: %1, %2 processors", c.first, c.second)); if (format() == 0) { throw MissingSettingError ("format"); diff --git a/src/lib/util.cc b/src/lib/util.cc index 66743250f..0fced638c 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -875,3 +875,29 @@ still_image_file (string f) return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png"); } + +/** @return A pair containing CPU model name and the number of processors */ +pair +cpu_info () +{ + pair info; + info.second = 0; + +#ifdef DVDOMATIC_POSIX + ifstream f ("/proc/cpuinfo"); + while (f.good ()) { + string l; + getline (f, l); + if (boost::algorithm::starts_with (l, "model name")) { + string::size_type const c = l.find (':'); + if (c != string::npos) { + info.first = l.substr (c + 2); + } + } else if (boost::algorithm::starts_with (l, "processor")) { + ++info.second; + } + } +#endif + + return info; +} diff --git a/src/lib/util.h b/src/lib/util.h index 0744d9c09..024c40fb5 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -280,6 +280,7 @@ private: extern int64_t video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float frames_per_second); extern bool still_image_file (std::string); +extern std::pair cpu_info (); #endif -- cgit v1.2.3