xref: /aosp_15_r20/external/golang-protobuf/encoding/protojson/bench_test.go (revision 1c12ee1efe575feb122dbf939ff15148a3b3e8f2)
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
5package protojson_test
6
7import (
8	"testing"
9
10	"google.golang.org/protobuf/encoding/protojson"
11
12	"google.golang.org/protobuf/types/known/durationpb"
13)
14
15func 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