| 66 | } |
| 67 | |
| 68 | int64_t ProcessStateInfo::GetBytes(const string& state_key) const { |
| 69 | ProcessStateMap::const_iterator it = process_state_map_.find(state_key); |
| 70 | if (it != process_state_map_.end()) { |
| 71 | vector<string> fields; |
| 72 | split(fields, it->second, is_any_of(" "), token_compress_on); |
| 73 | // We expect state_value such as, e.g., '16129508', '16129508 kB', '16129508 mB' |
| 74 | StringParser::ParseResult result; |
| 75 | int64_t state_value = StringParser::StringToInt<int64_t>(fields[0].data(), |
| 76 | fields[0].size(), &result); |
| 77 | if (result == StringParser::PARSE_SUCCESS) { |
| 78 | if (fields.size() < 2) return state_value; |
| 79 | if (fields[1].compare("kB") == 0) return state_value * 1024L; |
| 80 | } |
| 81 | } |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | void ProcessStateInfo::ReadProcIO() { |
| 86 | ifstream ioinfo("/proc/self/io", ios::in); |