# benchmark-mapstructure-and-deepcopy **Repository Path**: jinq0123/benchmark-mapstructure-and-deepcopy ## Basic Information - **Project Name**: benchmark-mapstructure-and-deepcopy - **Description**: 比较 mapstructure 和 deepcopy 的性能 - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # benchmark-mapstructure-and-deepcopy 比较 mapstructure 和 deepcopy 的性能 mapstructure.Encode() 可以将 map[string]interface{} 转为 struct, 该 struct 可以 deepcopy 得到一个副本,也可以再次 Encode() 得到一个副本, 2种方法对比下性能。 ``` D:\gitee\benchmark-mapstructure-and-deepcopy (master -> origin) λ go test -bench=. goos: windows goarch: amd64 pkg: bench BenchmarkDeepcopy-4 566760 2043 ns/op BenchmarkMapStructure-4 108110 11211 ns/op PASS ok bench 3.667s ``` 结论:deepcopy 更快