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

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 5687003: New heap profiler: add support for progress reporting and control. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years 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 | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index ac4afb2517c7b4bfd0e18d327f35019a155e3838..ad242fe79c1bb0a8d9ebd1d0d35dd42ae84a0833 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -1211,4 +1211,51 @@ TEST(HeapSnapshotGetNodeById) {
CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL));
}
+
+namespace {
+
+class TestActivityControl : public v8::ActivityControl {
+ public:
+ explicit TestActivityControl(int abort_count)
+ : done_(0), total_(0), abort_count_(abort_count) {}
+ ControlOption ReportProgressValue(int done, int total) {
+ done_ = done;
+ total_ = total;
+ return --abort_count_ != 0 ? kContinue : kAbort;
+ }
+ int done() { return done_; }
+ int total() { return total_; }
+
+ private:
+ int done_;
+ int total_;
+ int abort_count_;
+};
+}
+
+TEST(TakeHeapSnapshotAborting) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount();
+ TestActivityControl aborting_control(3);
+ const v8::HeapSnapshot* no_snapshot =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("abort"),
+ v8::HeapSnapshot::kFull,
+ &aborting_control);
+ CHECK_EQ(NULL, no_snapshot);
+ CHECK_EQ(snapshots_count, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_GT(aborting_control.total(), aborting_control.done());
+
+ TestActivityControl control(-1); // Don't abort.
+ const v8::HeapSnapshot* snapshot =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("full"),
+ v8::HeapSnapshot::kFull,
+ &control);
+ CHECK_NE(NULL, snapshot);
+ CHECK_EQ(snapshots_count + 1, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_EQ(control.total(), control.done());
+ CHECK_GT(control.total(), 0);
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
« no previous file with comments | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698