VTune performance .... from 4us on average (dual threads performance test) to 3us avarage

This commit is contained in:
KjellKod 2014-05-25 01:09:50 -06:00
parent fafa4cf96a
commit 9be8f49f66
2 changed files with 17 additions and 18 deletions

View File

@ -43,7 +43,7 @@ FileSink::~FileSink() {
} }
void FileSink::fileWrite(LogMessageMover message) { void FileSink::fileWrite(LogMessageMover message) {
std::ofstream& out(filestream()); std::ofstream& out(filestream());
out << message.get().toString() << std::flush; out << message.get().toString();
} }
std::string FileSink::changeLogFile(const std::string& directory) { std::string FileSink::changeLogFile(const std::string& directory) {

View File

@ -37,38 +37,37 @@ namespace {
namespace g2 { namespace g2 {
std::string LogMessage::toString() const { std::string LogMessage::toString() const {
std::ostringstream oss; std::string out;
oss << "\n" << timestamp() << "." << microseconds() << "\t"; out.append("\n" + timestamp() + "." + microseconds() + "\t"
oss << level() << " [" << file(); + level() + " [" + file() + " L: " + line() + "]\t");
oss << " L: " << line() << "]\t";
// Non-fatal Log Message // Non-fatal Log Message
if (false == wasFatal()) { if (false == wasFatal()) {
oss << '"' << message() << '"'; out.append('"' + message() + '"');
return oss.str(); return out;
} }
if (internal::FATAL_SIGNAL.value == _level.value) { if (internal::FATAL_SIGNAL.value == _level.value) {
oss.str(""); // clear any previous text and formatting out.clear(); // clear any previous text and formatting
oss << "\n" << timestamp() << "." << microseconds(); out.append("\n" + timestamp() + "." + microseconds()
oss << "\n\n***** FATAL SIGNAL RECEIVED ******* " << std::endl; + "\n\n***** FATAL SIGNAL RECEIVED ******* \n"
oss << '"' << message() << '"'; + '"' + message() + '"');
return oss.str(); return out;
} }
// Not crash scenario but LOG or CONTRACT // Not crash scenario but LOG or CONTRACT
auto level_value = _level.value; auto level_value = _level.value;
if (FATAL.value == level_value) { if (FATAL.value == level_value) {
oss << "\n\t*******\tEXIT trigger caused by LOG(FATAL) entry: \n\t"; out.append("\n\t*******\tEXIT trigger caused by LOG(FATAL) entry: \n\t"
oss << '"' << message() << '"'; + '"' + message() + '"');
} else if (internal::CONTRACT.value == level_value) { } else if (internal::CONTRACT.value == level_value) {
oss << "\n\t *******\tEXIT trigger caused by broken Contract: CHECK(" << _expression << ")\n\t"; out.append("\n\t *******\tEXIT trigger caused by broken Contract: CHECK(" + _expression + ")\n\t"
oss << '"' << message() << '"'; + '"' + message() + '"');
} else { } else {
oss << "\n\t*******\tUNKNOWN Log Message Type\n" << '"' << message() << '"'; out.append("\n\t*******\tUNKNOWN Log Message Type\n" + '"' + message() + '"');
} }
return oss.str(); return out;
} }
std::string LogMessage::timestamp(const std::string & time_look) const { std::string LogMessage::timestamp(const std::string & time_look) const {