diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-14 20:33:50 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-14 20:33:50 +0000 |
| commit | 3031638f0ddf23654b72af2088a7616791307310 (patch) | |
| tree | 4d0bbdaf3e2a5317c8e5d36a08241e5ba2b63f09 /src/lib/util.cc | |
| parent | fad726e94700bccdae0d301d54cdb1eab51cc71f (diff) | |
| parent | b9ee74b24dad91e3fee9ead44ea9a52328b20f25 (diff) | |
Merge master.
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 987c2b9e5..ef6f46575 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -878,3 +878,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; +} |
