summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-13 13:46:04 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-13 13:46:04 +0000
commit63cf599696abce2a4f67ba9d34697c5b804cd1c5 (patch)
tree8130a5718e5297cb855cb13196d829e96e7e708c
parent4dacdd078baedf0046e6bfe1f4fe42b2c12a1ca8 (diff)
Put CPU info into log, on POSIX at least.
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/util.cc26
-rw-r--r--src/lib/util.h1
3 files changed, 29 insertions, 0 deletions
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<string, int> 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<string, int>
+cpu_info ()
+{
+ pair<string, int> 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<std::string, int> cpu_info ();
#endif