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

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

Issue 16359016: Print accessors execution time in test-cpu-profiler/NativeAccessorNameInProfile1 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 5edfc912699bbd74b9687c6e9f48c8328a5a721d..901c1161fceea69cfbb2578ff2cfe230b71744c3 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -651,12 +651,14 @@ static const char* native_accessor_test_source = "function start(count) {\n"
class FooAccessorsData {
public:
explicit FooAccessorsData(int min_duration_ms)
- : min_duration_ms_(min_duration_ms) {}
+ : min_duration_ms_(min_duration_ms),
+ getter_duration_(0),
+ setter_duration_(0) {}
static v8::Handle<v8::Value> Getter(v8::Local<v8::String> name,
const v8::AccessorInfo& info) {
FooAccessorsData* data = fromInfo(info);
- data->Wait();
+ data->getter_duration_ = data->Wait();
return v8::Int32::New(2013);
}
@@ -664,15 +666,22 @@ class FooAccessorsData {
v8::Local<v8::Value> value,
const v8::AccessorInfo& info) {
FooAccessorsData* data = fromInfo(info);
- data->Wait();
+ data->setter_duration_ = data->Wait();
+ }
+
+ void PrintAccessorTime() {
+ i::OS::Print("getter: %f ms; setter: %f ms\n", getter_duration_,
+ setter_duration_);
}
private:
- void Wait() {
+ double Wait() {
double start = i::OS::TimeCurrentMillis();
- for (double duration = 0; duration < min_duration_ms_; ) {
+ double duration = 0;
+ while (duration < min_duration_ms_) {
duration = i::OS::TimeCurrentMillis() - start;
}
+ return duration;
}
static FooAccessorsData* fromInfo(const v8::AccessorInfo& info) {
@@ -681,6 +690,8 @@ class FooAccessorsData {
}
int min_duration_ms_;
+ double getter_duration_;
+ double setter_duration_;
};
@@ -723,6 +734,7 @@ TEST(NativeAccessorNameInProfile1) {
// Dump collected profile to have a better diagnostic in case of failure.
reinterpret_cast<i::CpuProfile*>(
const_cast<v8::CpuProfile*>(profile))->Print();
+ accessors.PrintAccessorTime();
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode = GetChild(root, "start");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698