From 284837daa07b29d6a63a748544a90b1f5842ac5c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 10 Sep 2012 19:10:20 +0200 Subject: Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073) New snapshot --- Source/WebKit2/Shared/WebMemorySampler.cpp | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'Source/WebKit2/Shared/WebMemorySampler.cpp') diff --git a/Source/WebKit2/Shared/WebMemorySampler.cpp b/Source/WebKit2/Shared/WebMemorySampler.cpp index bdbab2d2d..6f77843ce 100644 --- a/Source/WebKit2/Shared/WebMemorySampler.cpp +++ b/Source/WebKit2/Shared/WebMemorySampler.cpp @@ -30,11 +30,13 @@ #include #include +#include using namespace WebCore; namespace WebKit { +static const char separator = '\t'; WebMemorySampler* WebMemorySampler::shared() { @@ -45,8 +47,7 @@ WebMemorySampler* WebMemorySampler::shared() } WebMemorySampler::WebMemorySampler() - : m_separator(String("\t")) - , m_sampleTimer(this, &WebMemorySampler::sampleTimerFired) + : m_sampleTimer(this, &WebMemorySampler::sampleTimerFired) , m_stopTimer(this, &WebMemorySampler::stopTimerFired) , m_isRunning(false) , m_runningTime(0) @@ -102,7 +103,7 @@ void WebMemorySampler::stop() fflush(stdout); m_isRunning = false; - if(m_stopTimer.isActive()) + if (m_stopTimer.isActive()) m_stopTimer.stop(); if (m_sampleLogSandboxExtension) { @@ -134,21 +135,22 @@ void WebMemorySampler::initializeSandboxedLogFile(const SandboxExtension::Handle void WebMemorySampler::writeHeaders() { - String processDetails = String("Process: "); - processDetails.append(processName()); - processDetails.append(String("\n")); - writeToFile(m_sampleLogFile, processDetails.utf8().data(), processDetails.utf8().length()); + String processDetails = "Process: " + processName() + '\n'; + + CString utf8String = processDetails.utf8(); + writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length()); - String header; + StringBuilder header; WebMemoryStatistics stats = sampleWebKit(); if (!stats.keys.isEmpty()) { for (size_t i = 0; i < stats.keys.size(); ++i) { - header.append(m_separator); - header.append(stats.keys[i].utf8().data()); + header.append(separator); + header.append(stats.keys[i]); } } - header.append(String("\n")); - writeToFile(m_sampleLogFile, header.utf8().data(), header.utf8().length()); + header.append('\n'); + utf8String = header.toString().utf8(); + writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length()); } void WebMemorySampler::sampleTimerFired(Timer*) @@ -168,18 +170,20 @@ void WebMemorySampler::stopTimerFired(Timer*) void WebMemorySampler::appendCurrentMemoryUsageToFile(PlatformFileHandle& file) { // Collect statistics from allocators and get RSIZE metric - String statString; + StringBuilder statString; WebMemoryStatistics memoryStats = sampleWebKit(); if (!memoryStats.values.isEmpty()) { - statString.append(m_separator); + statString.append(separator); for (size_t i = 0; i < memoryStats.values.size(); ++i) { - statString.append(m_separator); - statString.append(String::format("%lu", memoryStats.values[i])); + statString.append(separator); + statString.append(String::number(memoryStats.values[i])); } } - statString.append(String("\n")); - writeToFile(m_sampleLogFile, statString.utf8().data(), statString.utf8().length()); + statString.append('\n'); + + CString utf8String = statString.toString().utf8(); + writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length()); } } -- cgit v1.2.1