The V8 profiler can be used to profile both the C++ and Javascript code executing.
http://code.google.com/p/v8/wiki/V8Profiler
Ex:
Produce a profiling trace:
./d8 --prof test.js
Output looks like:
function-creation,0x2f3200,0x61dca0 code-creation,LazyCompile,0x61e100,1428,"ProtocolPackage native d8.js:1150" code-creation,LazyCompile,0x61e760,202,"parse native json.js:61" function-creation,0x2e2a1c,0x61e760 code-creation,LazyCompile,0x61e880,142,"ParseJSONUnfiltered native json.js:30" function-creation,0x2e29e4,0x61e880 code-creation,Eval,0x61e960,108,""
Process the trace:
./tools/mac-tick-processor v8.log
Output looks like:
ticks parent name 27 20.5% v8::internal::CEntryStub::MajorKey 26 19.7% unibrow::Letter::Is 10 7.6% __mh_dylib_header 6 4.5% v8::internal::Scanner::ScanIdentifier 5 3.8% unibrow::Utf8::ReadBlock 1 20.0% Script: native string.js 3 2.3% v8::internal::Scanner::ScanJavaScript 3 2.3% ___keymgr_initializer
Erick
Afficher les réponses par date
I currently generate a single trace file for the entire execution of the interpreter, so traces can span several webpage loads. I haven't actually been able to find anything in JavaScriptCore itself to tell me when the user goes to a new webpage. Not sure if that matters or not, for the moment, but there is one issue I would like to discuss.
The issue is about how we want to track functions. All functions are objects, and so have a serial number assigned to them, like all other objects. I have been considering logging some information (source line number, source file name, function name, etc) when function objects are created. One issue, however, is that function objects get recreated every page load (everything is reloaded, including the entire JS heap).
I also have very little information to give about host functions aside from their name and perhaps the machine code address. Do you see this as a problem? Should I make more of an effort to keep track of which functions are the same across page loads, or should the trace analysis program take care of this?
On 2010-05-13, at 11:08 AM, chevalma@iro.umontreal.ca wrote:
I currently generate a single trace file for the entire execution of the interpreter, so traces can span several webpage loads. I haven't actually been able to find anything in JavaScriptCore itself to tell me when the user goes to a new webpage. Not sure if that matters or not, for the moment, but there is one issue I would like to discuss.
The issue is about how we want to track functions. All functions are objects, and so have a serial number assigned to them, like all other objects. I have been considering logging some information (source line number, source file name, function name, etc) when function objects are created. One issue, however, is that function objects get recreated every page load (everything is reloaded, including the entire JS heap).
I also have very little information to give about host functions aside from their name and perhaps the machine code address. Do you see this as a problem? Should I make more of an effort to keep track of which functions are the same across page loads, or should the trace analysis program take care of this?
If the JS interpreter recreates the function, then it should be treated as a new object. However, that function object will point to the same place in the source (line number, name, etc) so the analysis tool can take care of treating this as the same function (or not depending on the objective of the analysis). In other words, let the analysis tool do the "abstracting" of the trace information.
Marc