+Peter Marshall <petermarsh...@chromium.org>

On Wed, Nov 6, 2019 at 8:58 AM Darin Dimitrov <darin.dimit...@gmail.com>
wrote:

> I am trying to collect function execution data using the CpuProfiler class.
>
> I ran the following test (taken from here
> https://github.com/v8/v8/blob/master/test/cctest/test-cpu-profiler.cc#L677
> ):
>
> const char* src =
>     "function loop(timeout) {\n"
>     "  this.mmm = 0;\n"
>     "  var start = Date.now();\n"
>     "  do {\n"
>     "    var n = 1000;\n"
>     "    while(n > 1) {\n"
>     "      n--;\n"
>     "      this.mmm += n * n * n;\n"
>     "    }\n"
>     "  } while (Date.now() - start < timeout);\n"
>     "}\n"
>     "function delay() { loop(10); }\n"
>     "function bar() { delay(); }\n"
>     "function baz() { delay(); }\n"
>     "function foo() {\n"
>     "  delay();\n"
>     "  bar();\n"
>     "  delay();\n"
>     "  baz();\n"
>     "}\n"
>     "function start(duration) {\n"
>     "  var start = Date.now();\n"
>     "  do {\n"
>     "    foo();\n"
>     "  } while (Date.now() - start < duration);\n"
>     "}\n";
>
> Script::Compile(context, v8::String::NewFromUtf8(isolate, src).
> ToLocalChecked()).ToLocalChecked()->Run(context).ToLocalChecked();
> Local<v8::Function> startFunc = context->Global()->Get(context, v8::String
> ::NewFromUtf8(isolate, "start").ToLocalChecked()).ToLocalChecked().As<v8::
> Function>();
>
> Local<v8::String> title = v8::String::NewFromUtf8(isolate, "my_trace").
> ToLocalChecked();
> CpuProfiler* profiler = CpuProfiler::New(isolate);
> profiler->StartProfiling(title, false);
>
> Local<Value> result;
> Local<Value> args[] = { Number::New(isolate, 200) };
> assert(startFunc->Call(context, context->Global(), 1, args).ToLocal(&
> result));
>
> const CpuProfile* profile = profiler->StopProfiling(title);
> const CpuProfileNode* root = profile->GetTopDownRoot();
> int count = root->GetChildrenCount();
> for (int i = 0; i < count; ++i) {
>     const CpuProfileNode* child = root->GetChild(i);
>     v8::String::Utf8Value str(isolate, child->GetFunctionName());
>     const char* funcName = *str;
>     printf("%s\n", funcName);
> }
>
>
>
> The root CpuProfileNode contains only a single child element called
> "(program)".
>
> If I execute the same code on Android, I correctly get the following child
> functions: "(program)", "start" and "(garbage collector)".
>
> Do you have any idea what might be wrong with the CpuProfiler class in v8
> in jitless mode? Is CpuProfiler the correct class to use to collect
> function execution times or is there some newer method?
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-users/798f9464-88a1-464f-8fb8-6aa223ce5e57%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-users/798f9464-88a1-464f-8fb8-6aa223ce5e57%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAH3p7oP%3DOKA8UCZgxFrLehh3ULbWGF-FU0%2BdnXop2%3DuW574k%2Bw%40mail.gmail.com.

Reply via email to