2019-03-29 17:46:57 -07:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2019-05-14 12:44:37 -07:00
|
|
|
package protojson_test
|
2019-03-29 17:46:57 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-05-14 12:44:37 -07:00
|
|
|
"google.golang.org/protobuf/encoding/protojson"
|
2019-05-16 12:47:20 -07:00
|
|
|
|
|
|
|
"google.golang.org/protobuf/types/known/durationpb"
|
2019-03-29 17:46:57 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkUnmarshal_Duration(b *testing.B) {
|
|
|
|
input := []byte(`"-123456789.123456789s"`)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-05-16 12:47:20 -07:00
|
|
|
err := protojson.Unmarshal(input, &durationpb.Duration{})
|
2019-03-29 17:46:57 -07:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|