Bug 167515

Summary: Round CPU Usage diagnostic logging to 2 significant digits
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, commit-queue, kling, koivisto, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Chris Dumez 2017-01-27 10:31:14 PST
Round CPU Usage diagnostic logging to 2 significant digits.
Comment 1 Chris Dumez 2017-01-27 10:31:37 PST
<rdar://problem/30236297>
Comment 2 Chris Dumez 2017-01-27 11:00:38 PST
Created attachment 299943 [details]
Patch
Comment 3 Antti Koivisto 2017-01-27 11:49:20 PST
Comment on attachment 299943 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299943&action=review

> Source/WebKit2/UIProcess/PerActivityStateCPUUsageSampler.cpp:80
> +static String toStringRoundingSignificantFigures(double value, unsigned significantFigures)
> +{
> +    DecimalNumber decimal(value, RoundingSignificantFigures, significantFigures);
> +    NumberToLStringBuffer buffer;
> +    unsigned length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength);
> +    return String(buffer, length);
> +}

Is this somehow better than String::number(cpuUsage, 2)?
Comment 4 Chris Dumez 2017-01-27 12:09:19 PST
Comment on attachment 299943 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299943&action=review

>> Source/WebKit2/UIProcess/PerActivityStateCPUUsageSampler.cpp:80
>> +}
> 
> Is this somehow better than String::number(cpuUsage, 2)?

String::number() takes a number of "decimal digits". I really need a number of "significant figures". 10 has 1 significant figure. 10.2 has 3 significant figures.
Comment 5 WebKit Commit Bot 2017-01-27 12:34:32 PST
Comment on attachment 299943 [details]
Patch

Clearing flags on attachment: 299943

Committed r211295: <http://trac.webkit.org/changeset/211295>
Comment 6 WebKit Commit Bot 2017-01-27 12:34:37 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Antti Koivisto 2017-01-27 15:22:06 PST
> I really need a number
> of "significant figures". 10 has 1 significant figure. 10.2 has 3
> significant figures.

I thought that is what String::number() with precision argument does.
Comment 8 Chris Dumez 2017-01-27 15:34:33 PST
(In reply to comment #7)
> > I really need a number
> > of "significant figures". 10 has 1 significant figure. 10.2 has 3
> > significant figures.
> 
> I thought that is what String::number() with precision argument does.

Oh, I'll double check then. Using String::number() would be nicer indeed if it does what I want.