Esempio n. 1
0
void MatrixStat::DumpSimple(const std::string& parent, std::ostream& os) const {
  os.setf(std::ios::fixed);
  os << std::setprecision(2); 
  os << "[matrix_stat] {\"name\": \"" << parent << "\""
     << ", \"qps\": " << GetQps()
     << ", \"count\": " << GetCount()
     << ", \"avg\": " << GetAvg()
     << ", \"max\": " << GetMax()
     << ", \"min\": " << GetMin();
  if (HasTimeDistribute()) {
    os << ", \"99\": " << GetTimeDistribute(0.99)
       << ", \"95\": " << GetTimeDistribute(0.95)
       << ", \"90\": " << GetTimeDistribute(0.9)
       << ", \"80\": " << GetTimeDistribute(0.8)
       << ", \"50\": " << GetTimeDistribute(0.5);
  } else {
    os << ", \"value\": " << GetValue();
  }
  os << "}" << std::endl;

  if (HasResult()) {
    for (const auto& pair : child_) {
      std::string sub = parent + "." + pair.first; 
      pair.second.DumpSimple(sub, os);
    }
  }
}
Esempio n. 2
0
void MatrixStat::Dump(std::ostream& os) const {
  os.setf(std::ios::fixed);
  os << std::setprecision(2); 
  os << "{\"qps\": " << GetQps()
     << ", \"count\": " << GetCount()
     << ", \"avg\": " << GetAvg()
     << ", \"max\": " << GetMax()
     << ", \"min\": " << GetMin();
  if (HasTimeDistribute()) {
    os << ", \"99\": " << GetTimeDistribute(0.99)
       << ", \"95\": " << GetTimeDistribute(0.95)
       << ", \"90\": " << GetTimeDistribute(0.9)
       << ", \"80\": " << GetTimeDistribute(0.8)
       << ", \"50\": " << GetTimeDistribute(0.5);
  } else {
    os << ", \"value\": " << GetValue();
  }
  if (HasResult()) {
    os << ",\n    \"Result\": {";
    bool first = true;
    for (const auto& pair : child_) {
      if (first == true) {
        first = false;
        os << "\n      ";
      } else {
        os << ",\n      ";
      }
      os << "\"" << pair.first << "\": ";
      pair.second.Dump(os);
    }
    os << "}";
  }
  os << "}";
}
Esempio n. 3
0
void  MatchResult::GetString(int index, BString *result) {
	*result = "";
	if (HasResult(index)) {
		const char* s = fRegExp->startp[index];
		const char* e = fRegExp->endp[index];
		while (s != e) { *result << *s; s++; }
	}
}
Esempio n. 4
0
int32 MatchResult::EndPos(int index) const {
	if (HasResult(index)) {
		return fRegExp->endp[index] - fString;
	}
	return -1;
}
Esempio n. 5
0
int32 MatchResult::StartPos(int index) const {
	if (HasResult(index)) {
		return fRegExp->startp[index] - fString;
	}
	return -1;
}
Esempio n. 6
0
const char* MatchResult::Start(int index) const {
	if (HasResult(index)) {
		return fRegExp->startp[index];
	}
	return NULL;
}