bench_test.go 536 B

123456789101112131415161718192021222324
  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 protojson_test
  5. import (
  6. "testing"
  7. "google.golang.org/protobuf/encoding/protojson"
  8. "google.golang.org/protobuf/types/known/durationpb"
  9. )
  10. func BenchmarkUnmarshal_Duration(b *testing.B) {
  11. input := []byte(`"-123456789.123456789s"`)
  12. for i := 0; i < b.N; i++ {
  13. err := protojson.Unmarshal(input, &durationpb.Duration{})
  14. if err != nil {
  15. b.Fatal(err)
  16. }
  17. }
  18. }