I wish V8 would do this for us.  I'm about to implement this as well, 
though v8 is crashing soon after I start profiling (addressed in another 
thread).  

I would recommend you download the Chromium source and look at how it 
converts from V8's cpu profile data into the file.  See 
chromium\src\third_party\WebKit\Source\core\inspector\v8\V8ProfilerAgentImpl.cpp
 
for inspiration.

-Jim

On Wednesday, December 9, 2015 at 4:08:53 PM UTC-8, Jane Chen wrote:
>
> Thanks a lot!  It sure helps.
>
> I found CpuProfileNode.GetNodeId().  Maybe that's the pre-computed id 
> which is the same as what you show here?
>
> On Wednesday, December 9, 2015 at 2:09:49 PM UTC-8, Ben Noordhuis wrote:
>>
>> On Wed, Dec 9, 2015 at 8:55 PM, Jane Chen <[email protected]> wrote: 
>> > So you mean the integers in the samples array are indexes of 
>> > CpuProfileNodes?  But does CpuProfileNode have an index?  Still 
>> struggling 
>> > to see how to get the integers in the samples array. 
>>
>> You can map them to numeric indexes like this: 
>>
>>   int monotonic_counter = 0; 
>>   std::map<const v8::CpuProfileNode*, int> nodes; 
>>   std::vector<int> samples; 
>>   for (int i = 0; i < profile->GetSamplesCount(); i += 1) { 
>>     int& sample = nodes[profile->GetSample(i)]; 
>>     if (sample == 0) sample = ++monotonic_counter; 
>>     samples.push_back(sample); 
>>   } 
>>   // now write out |samples| 
>>
>> If you use an appropriately sized hash table instead of a map you can 
>> bring algorithm complexity down from O(n*lg n) to amortized O(n). 
>> Hope that helps. 
>>
>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to