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

Unified Diff: runtime/observatory/lib/src/repositories/sample_profile.dart

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Added page to Observatory to display native memory allocation information. Created 3 years, 9 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
Index: runtime/observatory/lib/src/repositories/sample_profile.dart
diff --git a/runtime/observatory/lib/src/repositories/sample_profile.dart b/runtime/observatory/lib/src/repositories/sample_profile.dart
index 5ad82824a65d5b4a86fb8581e7706ec7201249cc..2b96f2781734c48337dd1fe60646546e2801562f 100644
--- a/runtime/observatory/lib/src/repositories/sample_profile.dart
+++ b/runtime/observatory/lib/src/repositories/sample_profile.dart
@@ -32,10 +32,11 @@ class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
Stream<SampleProfileLoadingProgressEvent> get onProgress =>
_onProgress.stream;
- final S.Isolate isolate;
+ final Object owner;
Cutch 2017/03/21 20:27:11 Use the type ServiceObjectOwner instead of Object
bkonyi 2017/03/22 21:25:21 Done.
final S.Class cls;
final M.SampleProfileTag tag;
final bool clear;
+ final bool isCpuProfile;
Cutch 2017/03/21 20:27:11 isn't there an enum for the profile type? Use that
bkonyi 2017/03/22 21:25:21 Done.
M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching;
double _progress = 0.0;
@@ -49,21 +50,30 @@ class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
Duration get loadingTime => _loadingTime.elapsed;
CpuProfile get profile => _profile;
- SampleProfileLoadingProgress(this.isolate, this.tag, this.clear, {this.cls}) {
+ SampleProfileLoadingProgress(this.owner, this.tag, this.clear,
+ {this.isCpuProfile: true, this.cls}) {
_run();
}
Future _run() async {
_fetchingTime.start();
try {
- if (clear) {
- await isolate.invokeRpc('_clearCpuProfile', {});
+ if (clear && isCpuProfile) {
+ await owner.invokeRpc('_clearCpuProfile', {});
}
- final response = cls != null
+ var response;
+ if (isCpuProfile) {
+ response = cls != null
? await cls.getAllocationSamples(_tagToString(tag))
- : await isolate
+ : await owner
.invokeRpc('_getCpuProfile', {'tags': _tagToString(tag)});
+ } else {
+ assert(owner is M.VM);
+ M.VM vm = owner as M.VM;
+ response = await owner.invokeRpc('_getNativeAllocationSamples', {'tags':
+ _tagToString(tag)});
+ }
_fetchingTime.stop();
_loadingTime.start();
@@ -72,7 +82,7 @@ class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
CpuProfile profile = new CpuProfile();
- Stream<double> progress = profile.loadProgress(isolate, response);
+ Stream<double> progress = profile.loadProgress(owner, response);
progress.listen((value) {
_progress = value;
_triggerOnProgress();
@@ -124,7 +134,7 @@ class IsolateSampleProfileRepository
assert(forceFetch != null);
S.Isolate isolate = i as S.Isolate;
assert(isolate != null);
- if (_last != null && !clear && !forceFetch && _last.isolate == isolate) {
+ if (_last != null && !clear && !forceFetch && _last.owner == isolate) {
_last.reuse();
} else {
_last = new SampleProfileLoadingProgress(isolate, t, clear);
@@ -156,3 +166,21 @@ class ClassSampleProfileRepository implements M.ClassSampleProfileRepository {
return cls.setTraceAllocations(false);
}
}
+
+class NativeMemorySampleProfileRepository
+ implements M.NativeMemorySampleProfileRepository {
+ SampleProfileLoadingProgress _last;
+
+ Stream<SampleProfileLoadingProgressEvent> get(
+ M.VM vm, M.SampleProfileTag t, {bool forceFetch: false}) {
+ assert(forceFetch != null);
+ if (_last != null && !clear && !forceFetch) {
+ _last.reuse();
+ } else {
+ _last = new SampleProfileLoadingProgress(vm, t, false, isCpuProfile: false
+ );
+ }
+ return _last.onProgress;
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698