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