Put CPU info into log, on POSIX at least.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:46:04 +0000 (13:46 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:46:04 +0000 (13:46 +0000)
src/lib/film.cc
src/lib/util.cc
src/lib/util.h

index ad9f6525650e5cdebe54e70edb5349d796ce3d9c..f481399a97eb74b382e3d33094ba2af515e05155 100644 (file)
@@ -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");
index 66743250f18a3913eb9c0037411375445485d74e..0fced638cc47ad8954f8fe0ad9825d348e5a3498 100644 (file)
@@ -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;
+}
index 0744d9c090080806fac6438a322cd9a715c2e7c7..024c40fb555f32b4aa3045bbcb944682629fb749 100644 (file)
@@ -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