bench_test.go 520 B

1234567891011121314151617181920212223
  1. // Copyright 2019 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package jsonpb_test
  5. import (
  6. "testing"
  7. "google.golang.org/protobuf/encoding/jsonpb"
  8. knownpb "google.golang.org/protobuf/types/known"
  9. )
  10. func BenchmarkUnmarshal_Duration(b *testing.B) {
  11. input := []byte(`"-123456789.123456789s"`)
  12. for i := 0; i < b.N; i++ {
  13. err := jsonpb.Unmarshal(&knownpb.Duration{}, input)
  14. if err != nil {
  15. b.Fatal(err)
  16. }
  17. }
  18. }