ardielle / ardielle-tools

Apache License 2.0
18 stars 19 forks source link

Go: feature improve json Decode performance #96

Closed kpango closed 6 years ago

kpango commented 6 years ago

I fixed wasteful JSON Body parsing, Use json.Decoder instead of json.Unmarshal & ioutil.ReadAll for json-parsing performance improvement.

see this benchmark document.

before

    var target JSON
    body, err := ioutil.ReadAll(reader)
    if err != nil {
        return err
    }
    return json.Unmarshal(body, &target)

after

    var target JSON
    return json.NewDecoder(reader).Decode(&target)
yahoocla commented 6 years ago

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! :smile:

boynton commented 6 years ago

👍