Changed the profiler to use std::ostringstream as the text sink (instead of std::string)

This commit is contained in:
Nathan Woods 2017-05-29 18:29:34 -04:00 committed by Vas Crabb
parent 2b3b34cacd
commit e220816ed1

View File

@ -185,14 +185,15 @@ void real_profiler_state::update_text(running_machine &machine)
// this becomes the total; if we end up with 0 for anything, we were just started, so return empty
u64 total = computed;
m_text.clear();
if (total == 0 || normalize == 0)
{
m_text.clear();
return;
}
// loop over all types and generate the string
device_iterator iter(machine.root_device());
std::ostringstream stream;
for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_TOTAL; ++curtype)
{
// determine the accumulated time for this type
@ -202,28 +203,29 @@ void real_profiler_state::update_text(running_machine &machine)
if (computed != 0)
{
// start with the un-normalized percentage
m_text.append(string_format("%02d%% ", (int)((computed * 100 + total / 2) / total)));
util::stream_format(stream, "%02d%% ", (int)((computed * 100 + total / 2) / total));
// followed by the normalized percentage for everything but profiler and idle
if (curtype < PROFILER_PROFILER)
m_text.append(string_format("%02d%% ", (int)((computed * 100 + normalize / 2) / normalize)));
util::stream_format(stream, "%02d%% ", (int)((computed * 100 + normalize / 2) / normalize));
// and then the text
if (curtype >= PROFILER_DEVICE_FIRST && curtype <= PROFILER_DEVICE_MAX)
m_text.append(string_format("'%s'", iter.byindex(curtype - PROFILER_DEVICE_FIRST)->tag()));
util::stream_format(stream, "'%s'", iter.byindex(curtype - PROFILER_DEVICE_FIRST)->tag());
else
for (auto & name : names)
if (name.type == curtype)
{
m_text.append(name.string);
stream << name.string;
break;
}
// followed by a carriage return
m_text.append("\n");
stream << '\n';
}
}
// reset data set to 0
memset(m_data, 0, sizeof(m_data));
m_text = stream.str();
}