Re: [PerformanceTimeline] API/WebIDL related feedback

Le 23/08/2013 03:26, Nic Jansma a écrit :
>> I'm not sure I see the benefit of the getEntriesByType and 
>> getEntriesByName methods since what they do can be done very easily 
>> in JS:
>>
>>   var fooEntries = performance.entries.filter(function(e){return 
>> e.name === "foo"}) // ES5
>>   var fooEntries = performance.entries.filter(e => e.name === "foo") 
>> // ES6
>
> For performance reasons, the browser should be able to generate more 
> efficient lists when getEntriesByType() or getEntriesByName() are 
> called than you can filter on your own in JavaScript.  Imagine fore 
> example, you had 10,000 UserTiming marks and just 10 ResourceTiming 
> entries, and just wanted the 10 ResourceTiming entries.  The browser 
> should be able to more efficiently generate the list of 10 entries 
> than returning 10,010 entries and having JavaScript filter the rest.
In current Chrome on my laptop, filtering 10000 entries [1] takes 
~0.9ms. Not really something that is really worth optimizing for...
People also can implement a per-entryType cache mechanism themselves if 
that ever becomes a concern (and I imagine it won't for 90% of people).

David

[1] https://gist.github.com/DavidBruant/6316619

Received on Friday, 23 August 2013 08:02:08 UTC