2019-03-30 00:46:57 +00: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 19:44:37 +00:00
|
|
|
package protojson_test
|
2019-03-30 00:46:57 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-05-14 19:44:37 +00:00
|
|
|
"google.golang.org/protobuf/encoding/protojson"
|
2019-05-16 19:47:20 +00:00
|
|
|
|
|
|
|
"google.golang.org/protobuf/types/known/durationpb"
|
2019-03-30 00:46:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkUnmarshal_Duration(b *testing.B) {
|
|
|
|
input := []byte(`"-123456789.123456789s"`)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-05-16 19:47:20 +00:00
|
|
|
err := protojson.Unmarshal(input, &durationpb.Duration{})
|
2019-03-30 00:46:57 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|