diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-13 13:46:04 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-13 13:46:04 +0000 |
| commit | 63cf599696abce2a4f67ba9d34697c5b804cd1c5 (patch) | |
| tree | 8130a5718e5297cb855cb13196d829e96e7e708c /src/lib/util.cc | |
| parent | 4dacdd078baedf0046e6bfe1f4fe42b2c12a1ca8 (diff) | |
Put CPU info into log, on POSIX at least.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 26 |
1 files changed, 26 insertions, 0 deletions
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; +} |
