Bug 157608

Summary: Web Inspector: 3.5% of time in toFixed in TimelineRecordBar updating element positions
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: DoNotImportToRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Joseph Pecoraro
Reported 2016-05-11 21:56:43 PDT
* SUMMARY 3.5% of time in toFixed in TimelineRecordBar updating element positions _updateElementPosition's logic seems to be using toFixed(2) to compare two floats to 2 decimals of precision. Unfortunately toFixed is converting to a string and as a result is be very expensive. Especially since it is often not even needed. Stay in numbers by comparing a few counted numbers Math.round(num * 100) instead. In micro benchmarks this was a 40x faster way to compare random numbers.
Attachments
[PATCH] Proposed Fix (4.50 KB, patch)
2016-05-11 22:08 PDT, Joseph Pecoraro
no flags
Joseph Pecoraro
Comment 1 2016-05-11 22:08:16 PDT
Created attachment 278696 [details] [PATCH] Proposed Fix
WebKit Commit Bot
Comment 2 2016-05-12 00:23:03 PDT
Comment on attachment 278696 [details] [PATCH] Proposed Fix Clearing flags on attachment: 278696 Committed r200745: <http://trac.webkit.org/changeset/200745>
WebKit Commit Bot
Comment 3 2016-05-12 00:23:07 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.