File: unmarshal_test.go

package info (click to toggle)
golang-github-dhowett-go-plist 0.0~git20160708.0.fec78c8-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 284 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package plist

import (
	"reflect"
	"testing"
	"time"
)

func BenchmarkStructUnmarshal(b *testing.B) {
	type Data struct {
		Intarray []uint64  `plist:"intarray"`
		Floats   []float64 `plist:"floats"`
		Booleans []bool    `plist:"booleans"`
		Strings  []string  `plist:"strings"`
		Dat      []byte    `plist:"data"`
		Date     time.Time `plist:"date"`
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		var xval Data
		d := &Decoder{}
		d.unmarshal(plistValueTree, reflect.ValueOf(&xval))
	}
}

func BenchmarkInterfaceUnmarshal(b *testing.B) {
	for i := 0; i < b.N; i++ {
		var xval interface{}
		d := &Decoder{}
		d.unmarshal(plistValueTree, reflect.ValueOf(&xval))
	}
}