Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: pkg/analysis_server/lib/src/utilities/profiling.dart

Issue 2959643002: Fix an issue calculating analysis server cpu usage. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/utilities/profiling_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/utilities/profiling.dart
diff --git a/pkg/analysis_server/lib/src/utilities/profiling.dart b/pkg/analysis_server/lib/src/utilities/profiling.dart
index aa3335f6019d96329b771d6b80cdf2740e2f080c..7e2e49bc6262fc55456e2583266a767999ff7375 100644
--- a/pkg/analysis_server/lib/src/utilities/profiling.dart
+++ b/pkg/analysis_server/lib/src/utilities/profiling.dart
@@ -32,15 +32,19 @@ class UsageInfo {
/// never more than slightly above 100.0).
final double cpuPercentage;
- /// The process memory usage in bytes.
+ /// The process memory usage in kilobytes.
final int memoryKB;
UsageInfo(this.cpuPercentage, this.memoryKB);
double get memoryMB => memoryKB / 1024;
+
+ String toString() => '$cpuPercentage% ${memoryMB.toStringAsFixed(1)}MB';
}
class _PosixProcessProfiler extends ProcessProfiler {
+ static final RegExp stringSplitRegExp = new RegExp(r'\s+');
+
_PosixProcessProfiler() : super._();
@override
@@ -76,7 +80,7 @@ class _PosixProcessProfiler extends ProcessProfiler {
try {
// " 0.0 378940"
String line = psResults.split('\n').first.trim();
- List<String> values = line.split(' ');
+ List<String> values = line.split(stringSplitRegExp);
return new UsageInfo(double.parse(values[0]), int.parse(values[1]));
} catch (e) {
return null;
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/utilities/profiling_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698