dogfootman.com

  • 홈
  • 태그
  • 방명록

deep copy 2

[Go] 구조체를 여러가지 방법으로 깊은 복사 하는 방법 + 성능비교 (How to deep copy a struct in various ways + Performance comparison)

개요구조체를 여러가지 방법으로 깊은 복사각 복사 방법의 성능 비교 (Benchmark)벤치마크 참고: https://dogfootman.com/14 [Go] Benchmark 사용법 (How to Use Benchmarks)개요Benchmark의 사용법   1. 기본 사용법func BenchmarkXxx(*testing.B) 의 형태를 가지고 있으면 벤치마크로 간주되며-bench 의 플러그가 있으면 go test 의 명령에 의해서 실행된다  샘플코드package main...fdogfootman.com  1. 수동으로 깊은 복사package mainimport "fmt"type Address struct { City string State string}type Student struct { ..

[Go] 2024.06.25

[Go] 슬라이스의 얕은 복사와 깊은 복사 (Shallow Copy and Deep Copy of Slices)

개요 슬라이스의 얕은 복사와 깊은 복사에 대해서 1. 얕은 복사 package main import ( "fmt" "sort" ) type obj struct { Name string Age int32 } func main() { list1 := []*obj{ {Name: "A", Age: 1}, {Name: "B", Age: 2}, {Name: "C", Age: 3}, } list2 := list1 sort.Slice(list2, func(i, j int) bool { return list2[i].Age < list2[j].Age }) fmt.Printf("List1 [%p]\n", list1) for _, item := range list1 { fmt.Printf("Name: %s, Age: %d [..

[Go] 2023.08.03
이전
1
다음
더보기
  • View All Categories (13)
    • [Unity] (3)
      • [Unity 2D] (3)
    • [Go] (9)
    • [ETC] (1)

Tag

benchmark, struct, cycle not allowed, scroll wheel, go, API, Slice, Golang, Unity, pre-request script, Camera, mouse position, deep copy, Performance, Dependency, test, Unity 2D, gob, 고랭, Interface,

최근글과 인기글

  • 최근글
  • 인기글

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바