From 293cf81cf10f9f79a4758fad211052aed689d2d8 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 31 Oct 2018 09:57:37 +0800 Subject: [PATCH] =?UTF-8?q?gconv=E5=A2=9E=E5=8A=A0=E5=9F=BA=E5=87=86?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/util/gconv/gconv_test.go | 137 +++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 g/util/gconv/gconv_test.go diff --git a/g/util/gconv/gconv_test.go b/g/util/gconv/gconv_test.go new file mode 100644 index 000000000..b740eb2ff --- /dev/null +++ b/g/util/gconv/gconv_test.go @@ -0,0 +1,137 @@ +// Copyright 2017-2018 gf Author(https://gitee.com/johng/gf). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://gitee.com/johng/gf. + +// go test *.go -bench=".*" -benchmem + +package gconv + +import ( + "testing" +) + +var value = 123456789 + +func BenchmarkString(b *testing.B) { + for i := 0; i < b.N; i++ { + String(value) + } +} + +func BenchmarkInt(b *testing.B) { + for i := 0; i < b.N; i++ { + Int(value) + } +} + +func BenchmarkInt8(b *testing.B) { + for i := 0; i < b.N; i++ { + Int8(value) + } +} + +func BenchmarkInt16(b *testing.B) { + for i := 0; i < b.N; i++ { + Int16(value) + } +} + +func BenchmarkInt32(b *testing.B) { + for i := 0; i < b.N; i++ { + Int32(value) + } +} + +func BenchmarkInt64(b *testing.B) { + for i := 0; i < b.N; i++ { + Int(value) + } +} + +func BenchmarkUint(b *testing.B) { + for i := 0; i < b.N; i++ { + Uint(value) + } +} + +func BenchmarkUint8(b *testing.B) { + for i := 0; i < b.N; i++ { + Uint8(value) + } +} + +func BenchmarkUint16(b *testing.B) { + for i := 0; i < b.N; i++ { + Uint16(value) + } +} + +func BenchmarkUint32(b *testing.B) { + for i := 0; i < b.N; i++ { + Uint32(value) + } +} + +func BenchmarkUint64(b *testing.B) { + for i := 0; i < b.N; i++ { + Uint64(value) + } +} + +func BenchmarkFloat32(b *testing.B) { + for i := 0; i < b.N; i++ { + Float32(value) + } +} + +func BenchmarkFloat64(b *testing.B) { + for i := 0; i < b.N; i++ { + Float64(value) + } +} + + +func BenchmarkTime(b *testing.B) { + for i := 0; i < b.N; i++ { + Time(value) + } +} + +func BenchmarkTimeDuration(b *testing.B) { + for i := 0; i < b.N; i++ { + TimeDuration(value) + } +} + + +func BenchmarkBytes(b *testing.B) { + for i := 0; i < b.N; i++ { + Bytes(value) + } +} + +func BenchmarkStrings(b *testing.B) { + for i := 0; i < b.N; i++ { + Strings(value) + } +} + +func BenchmarkInts(b *testing.B) { + for i := 0; i < b.N; i++ { + Ints(value) + } +} + +func BenchmarkFloats(b *testing.B) { + for i := 0; i < b.N; i++ { + Floats(value) + } +} + +func BenchmarkInterfaces(b *testing.B) { + for i := 0; i < b.N; i++ { + Interfaces(value) + } +} \ No newline at end of file