On processing speed in #Golang

Reading 1,000,000 ints from raw os.Stdin with fmt.Fscan took ~24s.

Wrapping os.Stdin in a bufio.Reader got it to ~2.2s.

Wrapping os.Stdin in a bufio.Scanner and using strconv.Atoi to parse token strings got it to ~450ms.

Parsing the tokens from bufio.Scanner manually as bytes without string allocations got it to ~280ms.

– From a discussion on the go-nuts mailing list

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s