diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebKit2/Shared/WebMemorySampler.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebKit2/Shared/WebMemorySampler.cpp')
-rw-r--r-- | Source/WebKit2/Shared/WebMemorySampler.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
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 <stdio.h> #include <wtf/text/CString.h> +#include <wtf/text/StringBuilder.h> 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<WebMemorySampler>*) @@ -168,18 +170,20 @@ void WebMemorySampler::stopTimerFired(Timer<WebMemorySampler>*) 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()); } } |