diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 04:55:06 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 04:55:06 +0000 |
commit | 022eab67d0b3476ee1d35cb463990170c982429b (patch) | |
tree | b2c5517fa9e5f7a0fd7ac6938f6cac80d250d797 /base | |
parent | 40d9ddf8fae7521890415be1eb0d2ad8f18453a9 (diff) | |
download | chromium_src-022eab67d0b3476ee1d35cb463990170c982429b.zip chromium_src-022eab67d0b3476ee1d35cb463990170c982429b.tar.gz chromium_src-022eab67d0b3476ee1d35cb463990170c982429b.tar.bz2 |
Mac: UI tweaks for task manager.
Nib change: Reduce row height, make scrollbars smaller.
Make text in task manager table slightly smaller.
Show in decimal digit for %cpu.
Show memory in KB/MB, not always in K.
Change update frequency from 1s to 2s to match Activity Monitor's default.
(all mac-only. ui team is fine with this.)
Finally, turn taskman on.
BUG=13156
TEST=Open task manager, look at it. Should look & feel similar to Activity Monitor.
Review URL: http://codereview.chromium.org/536038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util.h | 8 | ||||
-rw-r--r-- | base/process_util_linux.cc | 2 | ||||
-rw-r--r-- | base/process_util_mac.mm | 6 | ||||
-rw-r--r-- | base/process_util_win.cc | 2 | ||||
-rw-r--r-- | base/string_util.cc | 10 | ||||
-rw-r--r-- | base/string_util.h | 16 | ||||
-rw-r--r-- | base/string_util_unittest.cc | 28 | ||||
-rw-r--r-- | base/trace_event.cc | 2 |
8 files changed, 36 insertions, 38 deletions
diff --git a/base/process_util.h b/base/process_util.h index eb21188..1dc01df 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -429,10 +429,10 @@ class ProcessMetrics { // Returns the CPU usage in percent since the last time this method was // called. The first time this method is called it returns 0 and will return // the actual CPU info on subsequent calls. - // Note that on multi-processor machines, the CPU usage value is for all - // CPUs. So if you have 2 CPUs and your process is using all the cycles - // of 1 CPU and not the other CPU, this method returns 50. - int GetCPUUsage(); + // On Windows, the CPU usage value is for all CPUs. So if you have 2 CPUs and + // your process is using all the cycles of 1 CPU and not the other CPU, this + // method returns 50. + double GetCPUUsage(); // Retrieves accounting information for all I/O operations performed by the // process. diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index a4b2603..29147f1 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -408,7 +408,7 @@ static int GetProcessCPU(pid_t pid) { return total_cpu; } -int ProcessMetrics::GetCPUUsage() { +double ProcessMetrics::GetCPUUsage() { // This queries the /proc-specific scaling factor which is // conceptually the system hertz. To dump this value on another // system, try diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index a7875f3..509828b 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -248,7 +248,7 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { (r)->tv_usec = (a)->microseconds; \ } while (0) -int ProcessMetrics::GetCPUUsage() { +double ProcessMetrics::GetCPUUsage() { mach_port_t task = TaskForPid(process_); if (task == MACH_PORT_NULL) return 0; @@ -307,8 +307,8 @@ int ProcessMetrics::GetCPUUsage() { return 0; // We add time_delta / 2 so the result is rounded. - int cpu = static_cast<int>((system_time_delta * 100 + time_delta / 2) / - (time_delta)); + double cpu = static_cast<double>( + (system_time_delta * 100.0 + time_delta / 2.0) / time_delta); last_system_time_ = task_time; last_time_ = time; diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 4d74226..d00e1de 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -608,7 +608,7 @@ static uint64 FileTimeToUTC(const FILETIME& ftime) { return li.QuadPart; } -int ProcessMetrics::GetCPUUsage() { +double ProcessMetrics::GetCPUUsage() { FILETIME now; FILETIME creation_time; FILETIME exit_time; diff --git a/base/string_util.cc b/base/string_util.cc index 6bb91da..3a5cef3 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -874,9 +874,9 @@ DataUnits GetByteDisplayUnits(int64 bytes) { // This must match the DataUnits enum. static const int64 kUnitThresholds[] = { 0, // DATA_UNITS_BYTE, - 3*1024, // DATA_UNITS_KILOBYTE, - 2*1024*1024, // DATA_UNITS_MEGABYTE, - 1024*1024*1024 // DATA_UNITS_GIGABYTE, + 3*1024, // DATA_UNITS_KIBIBYTE, + 2*1024*1024, // DATA_UNITS_MEBIBYTE, + 1024*1024*1024 // DATA_UNITS_GIBIBYTE, }; if (bytes < 0) { @@ -890,7 +890,7 @@ DataUnits GetByteDisplayUnits(int64 bytes) { break; } - DCHECK(unit_index >= DATA_UNITS_BYTE && unit_index <= DATA_UNITS_GIGABYTE); + DCHECK(unit_index >= DATA_UNITS_BYTE && unit_index <= DATA_UNITS_GIBIBYTE); return DataUnits(unit_index); } @@ -919,7 +919,7 @@ std::wstring FormatBytesInternal(int64 bytes, return std::wstring(); } - DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_GIGABYTE); + DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_GIBIBYTE); // Put the quantity in the right units. double unit_amount = static_cast<double>(bytes); diff --git a/base/string_util.h b/base/string_util.h index ee70a16..dd0f8c1 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -339,13 +339,11 @@ inline bool IsWhitespace(wchar_t c) { return wcschr(kWhitespaceWide, c) != NULL; } -// TODO(mpcomplete): Decide if we should change these names to KIBI, etc, -// or if we should actually use metric units, or leave as is. enum DataUnits { DATA_UNITS_BYTE = 0, - DATA_UNITS_KILOBYTE, - DATA_UNITS_MEGABYTE, - DATA_UNITS_GIGABYTE, + DATA_UNITS_KIBIBYTE, + DATA_UNITS_MEBIBYTE, + DATA_UNITS_GIBIBYTE, }; // Return the unit type that is appropriate for displaying the amount of bytes @@ -354,13 +352,13 @@ DataUnits GetByteDisplayUnits(int64 bytes); // Return a byte string in human-readable format, displayed in units appropriate // specified by 'units', with an optional unit suffix. -// Ex: FormatBytes(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB" -// Ex: FormatBytes(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1" +// Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB" +// Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units); // As above, but with "/s" units. -// Ex: FormatSpeed(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB/s" -// Ex: FormatSpeed(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1" +// Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB/s" +// Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units); // Return a number formated with separators in the user's locale way. diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 7e3062a..2c1f484 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -326,10 +326,10 @@ TEST(StringUtilTest, GetByteDisplayUnits) { } cases[] = { {0, DATA_UNITS_BYTE}, {512, DATA_UNITS_BYTE}, - {10*1024, DATA_UNITS_KILOBYTE}, - {10*1024*1024, DATA_UNITS_MEGABYTE}, - {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE}, - {~(1LL<<63), DATA_UNITS_GIGABYTE}, + {10*1024, DATA_UNITS_KIBIBYTE}, + {10*1024*1024, DATA_UNITS_MEBIBYTE}, + {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE}, + {~(1LL<<63), DATA_UNITS_GIBIBYTE}, #ifdef NDEBUG {-1, DATA_UNITS_BYTE}, #endif @@ -348,18 +348,18 @@ TEST(StringUtilTest, FormatBytes) { } cases[] = { {0, DATA_UNITS_BYTE, L"0", L"0 B"}, {512, DATA_UNITS_BYTE, L"512", L"512 B"}, - {512, DATA_UNITS_KILOBYTE, L"0.5", L"0.5 kB"}, - {1024*1024, DATA_UNITS_KILOBYTE, L"1024", L"1024 kB"}, - {1024*1024, DATA_UNITS_MEGABYTE, L"1", L"1 MB"}, - {1024*1024*1024, DATA_UNITS_GIGABYTE, L"1", L"1 GB"}, - {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE, L"10", L"10 GB"}, - {~(1LL<<63), DATA_UNITS_GIGABYTE, L"8589934592", L"8589934592 GB"}, + {512, DATA_UNITS_KIBIBYTE, L"0.5", L"0.5 kB"}, + {1024*1024, DATA_UNITS_KIBIBYTE, L"1024", L"1024 kB"}, + {1024*1024, DATA_UNITS_MEBIBYTE, L"1", L"1 MB"}, + {1024*1024*1024, DATA_UNITS_GIBIBYTE, L"1", L"1 GB"}, + {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10", L"10 GB"}, + {~(1LL<<63), DATA_UNITS_GIBIBYTE, L"8589934592", L"8589934592 GB"}, // Make sure the first digit of the fractional part works. - {1024*1024 + 103, DATA_UNITS_KILOBYTE, L"1024.1", L"1024.1 kB"}, - {1024*1024 + 205 * 1024, DATA_UNITS_MEGABYTE, L"1.2", L"1.2 MB"}, - {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIGABYTE, + {1024*1024 + 103, DATA_UNITS_KIBIBYTE, L"1024.1", L"1024.1 kB"}, + {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, L"1.2", L"1.2 MB"}, + {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIBIBYTE, L"1.9", L"1.9 GB"}, - {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE, L"10", L"10 GB"}, + {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10", L"10 GB"}, #ifdef NDEBUG {-1, DATA_UNITS_BYTE, L"", L""}, #endif diff --git a/base/trace_event.cc b/base/trace_event.cc index ff834ea..fbfd426 100644 --- a/base/trace_event.cc +++ b/base/trace_event.cc @@ -83,7 +83,7 @@ void TraceLog::Stop() { } void TraceLog::Heartbeat() { - std::string cpu = StringPrintf("%d", process_metrics_->GetCPUUsage()); + std::string cpu = StringPrintf("%.0f", process_metrics_->GetCPUUsage()); TRACE_EVENT_INSTANT("heartbeat.cpu", 0, cpu); } |