---
title: "安全类型-性能测试"
url: "https://goframe.org/docs/components/container-gtype-benchmark"
markdown_url: "https://goframe.org/docs/components/container-gtype-benchmark.md"
locale: "zh-Hans"
version: "2.10.x(Latest)"
section: "组件列表"
category: "组件列表 / 数据结构 / 安全类型-gtype"
published: "2024-10-21"
updated: "2024-11-11"
description: "展示了GoFrame框架中gtype包的安全类型性能基准测试结果，通过详细测试数据对比，分析不同数据类型的方法执行效率，为Go语言的开发者提供参考，提高并发编程中的数据处理能力。"
keywords: ["GoFrame", "GoFrame框架", "基准测试", "性能测试", "安全类型", "并发编程", "数据类型", "Go语言", "代码优化", "测试结果"]
---

# 安全类型-性能测试

基准测试结果如下：

```
john@john-B85M:~/Workspace/Go/GOPATH/src/github.com/gogf/gf/v2/container/gtype$ go test -bench=".*"  -benchmem
goos: linux
goarch: amd64
pkg: github.com/gogf/gf/v2/container/gtype
BenchmarkInt_Set-4            300000000           5.87 ns/op        0 B/op        0 allocs/op
BenchmarkInt_Val-4            2000000000          0.46 ns/op        0 B/op        0 allocs/op
BenchmarkInt_Add-4            300000000           5.86 ns/op        0 B/op        0 allocs/op
BenchmarkInt32_Set-4          300000000           5.87 ns/op        0 B/op        0 allocs/op
BenchmarkInt32_Val-4          2000000000          0.47 ns/op        0 B/op        0 allocs/op
BenchmarkInt32_Add-4          300000000           5.85 ns/op        0 B/op        0 allocs/op
BenchmarkInt64_Set-4          300000000           5.88 ns/op        0 B/op        0 allocs/op
BenchmarkInt64_Val-4          2000000000          0.46 ns/op        0 B/op        0 allocs/op
BenchmarkInt64_Add-4          300000000           5.88 ns/op        0 B/op        0 allocs/op
BenchmarkUint_Set-4           300000000           5.88 ns/op        0 B/op        0 allocs/op
BenchmarkUint_Val-4           2000000000          0.46 ns/op        0 B/op        0 allocs/op
BenchmarkUint_Add-4           300000000           5.87 ns/op        0 B/op        0 allocs/op
BenchmarkUint32_Set-4         300000000           5.86 ns/op        0 B/op        0 allocs/op
BenchmarkUint32_Val-4         2000000000          0.50 ns/op        0 B/op        0 allocs/op
BenchmarkUint32_Add-4         200000000           5.86 ns/op        0 B/op        0 allocs/op
BenchmarkUint64_Set-4         300000000           5.86 ns/op        0 B/op        0 allocs/op
BenchmarkUint64_Val-4         2000000000          0.47 ns/op        0 B/op        0 allocs/op
BenchmarkUint64_Add-4         300000000           5.85 ns/op        0 B/op        0 allocs/op
BenchmarkBool_Set-4           300000000           5.85 ns/op        0 B/op        0 allocs/op
BenchmarkBool_Val-4           2000000000          0.46 ns/op        0 B/op        0 allocs/op
BenchmarkString_Set-4         20000000            90.1 ns/op       23 B/op        1 allocs/op
BenchmarkString_Val-4         2000000000          1.58 ns/op        0 B/op        0 allocs/op
BenchmarkBytes_Set-4          20000000            76.2 ns/op       35 B/op        2 allocs/op
BenchmarkBytes_Val-4          2000000000          1.58 ns/op        0 B/op        0 allocs/op
BenchmarkInterface_Set-4      50000000            30.7 ns/op        8 B/op        0 allocs/op
BenchmarkInterface_Val-4      2000000000          0.74 ns/op        0 B/op        0 allocs/op
BenchmarkAtomicValue_Store-4  50000000            27.3 ns/op        8 B/op        0 allocs/op
BenchmarkAtomicValue_Load-4   2000000000          0.73 ns/op        0 B/op        0 allocs/op
PASS
ok   github.com/gogf/gf/v2/container/gtype 49.454s
```
