Commit 13075ed4 authored by Shenghou Ma's avatar Shenghou Ma

test/bench/go1: use raw string instead of string addition

to reduce compile time memory/stack usage.
Update #4970
$ go test -c ../test/bench/go1
before:
0.36user 0.07system 0:00.44elapsed 100%CPU
(0avgtext+0avgdata 540720maxresident)k
0inputs+19840outputs (0major+56451minor)pagefaults 0swaps
after:
0.33user 0.05system 0:00.39elapsed 100%CPU
(0avgtext+0avgdata 289936maxresident)k
0inputs+19864outputs (0major+29615minor)pagefaults 0swaps

And stack usage is reduced to below 1MiB.

R=golang-dev, r, dave
CC=golang-dev
https://golang.org/cl/7436050
parent 9744c0e1
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
package go1 package go1
import ( import (
"bytes"
"compress/bzip2" "compress/bzip2"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"io" "io"
"io/ioutil" "io/ioutil"
"strings"
"testing" "testing"
) )
...@@ -23,7 +23,7 @@ var ( ...@@ -23,7 +23,7 @@ var (
func makeJsonBytes() []byte { func makeJsonBytes() []byte {
var r io.Reader var r io.Reader
r = strings.NewReader(jsonbz2_base64) r = bytes.NewReader(bytes.Replace(jsonbz2_base64, []byte{'\n'}, nil, -1))
r = base64.NewDecoder(base64.StdEncoding, r) r = base64.NewDecoder(base64.StdEncoding, r)
r = bzip2.NewReader(r) r = bzip2.NewReader(r)
b, err := ioutil.ReadAll(r) b, err := ioutil.ReadAll(r)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment