Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(392)

Issue 145020043: code review 145020043: fmt: Improved printing performance for integers.

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 7 months ago by Leonhard Holz
Modified:
9 years, 7 months ago
Visibility:
Public.

Description

fmt: Improved printing performance for integers. Related to issue 3463. The special casing for base10 and base2^n is copied from strconv.Itoa(). Of course this is code duplication which should be avoided but neither fmt nor strconv expose a usable interface to use the integer format routine of the other package. Itoa cannot use fmt.Sprint because there is no format string for generic bases, fmt cannot use strconv.Itoa because Itoa does not offer uppercase digits (ABCDEF..). Performance stats for the following program: package main import "fmt" import "runtime/pprof" import "os" import "bufio" func main() { f, _ := os.Create("print_buf.prof") pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() b := bufio.NewWriter(os.Stdout) for i := 0; i < 1<<25; i++ { fmt.Fprintln(b, i) } } =========== Old ============================= User time (seconds): 26.69 System time (seconds): 5.31 Percent of CPU this job got: 138% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:23.04 =========== New ============================= User time (seconds): 14.84 System time (seconds): 2.77 Percent of CPU this job got: 141% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:12.43

Patch Set 1 : diff -r 6b163ec2122a172030284060788f535ab3b9d0e3 https://code.google.com/p/go #

Patch Set 2 : diff -r 6b163ec2122a172030284060788f535ab3b9d0e3 https://code.google.com/p/go #

Patch Set 3 : diff -r 6b163ec2122a172030284060788f535ab3b9d0e3 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -5 lines) Patch
M src/fmt/format.go View 1 2 3 chunks +44 lines, -5 lines 0 comments Download

Messages

Total messages: 7
Leonhard Holz
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
9 years, 7 months ago (2014-09-17 13:02:52 UTC) #1
bradfitz
Instead of code duplication, you should investigate moving any necessary shared code to a new ...
9 years, 7 months ago (2014-09-17 18:42:45 UTC) #2
Leonhard Holz
On 2014/09/17 18:42:45, bradfitz wrote: > Instead of code duplication, you should investigate moving any ...
9 years, 7 months ago (2014-09-17 20:48:30 UTC) #3
bradfitz
Well, it's too late for Go 1.4 anyway, so you have plenty of time to ...
9 years, 7 months ago (2014-09-17 20:49:46 UTC) #4
Leonhard Holz
Can you give me some hints where the other itoa methods are? On 2014/09/17 20:49:46, ...
9 years, 7 months ago (2014-09-18 05:42:43 UTC) #5
bradfitz
The tree is closed for changes like this for 3 months. Please open a bug ...
9 years, 7 months ago (2014-09-19 03:26:28 UTC) #6
bradfitz
9 years, 7 months ago (2014-09-29 19:29:55 UTC) #7
R=close

Addressed recently by r@ in
https://code.google.com/p/go/source/detail?r=f0cbfc3381c4

changeset:   21260:f0cbfc3381c4
user:        Rob Pike <r@golang.org>
date:        Mon Sep 22 11:58:15 2014 -0700
summary:     fmt: make printing of ints 25-35% faster
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b