[Locust] 2. Locust를 통한 언어와 프레임워크 별 테스트
·
Python/Open Source
테스트용 Locust 설정 locust.conf locustfile = locust_impl.py headless = true expect-workers = 5 host = http://localhost:8000 users = 10 spawn-rate = 10 run-time = 30s locust_impl.py from locust import task, FastHttpUser class TargetURL: ROOT = "/" STRING = "/string" JSON = "/json" CALC = "/calc" class LocustImpl(FastHttpUser): @task def root(self): self.client.get(TargetURL.ROOT) @task def string(self..
[Go] Time
·
Go
Golang Time 패키지 Time struct type Time struct { wall uint64 ext int64 loc *Location } Time 생성 방법 time.now() time.Date(year int, month Month...) time.Unix(sec int64, nsec int64) Time Test func TestTime(t *testing.T) { now := time.Now() t.Log(now) // 2022-08-02 11:14:48.8866312 +0900 KST m=+0.002534901 nowFormat := time.Now().Format("2006-01-02 15:04:05") t.Log(nowFormat) // 2022-08-02 11:17:33 (ht..
[Go] Factory Pattern(팩토리 패턴) 구현
·
Go
Factory Pattern 운송업체별로 물리 프린터기 출력용지나 출력물 등 달라지는데 여기서는 물리 프린터기에서 출력을 위한 데이터를 팩토리 패턴으로 구현 하였다. PrineterMethod Interface 구현 EMSPrinter, SFPrinter struct 구현 → GetOuput() 구현 Create() 를 통해서 new() 로 사용할 Prineter를 Create and Return Return Struct의 GetOuput() 메소드를 통해 결과값 Return factory.go package factory import ( "errors" "fmt" ) const ( EMS_CODE = "EMS" SF_CODE = "SF" ) type PrinterMethod interface { Get..
[Go] Channel 이용한 Queue
·
Go
package channel import ( "fmt" "math/rand" ) const QUEUE_SIZE = 20 var queue = newChannelQueue(QUEUE_SIZE) type ChannelQueue struct { data chan any } func newChannelQueue(size int) *ChannelQueue { return &ChannelQueue{ data: make(chan any, size), } } func (q *ChannelQueue) get() any { return
[Go] Int, String, Struct 정렬
·
Go
Input package sorts import ( "fmt" "sort" ) type person struct { name string age int loc *location } type location struct { nation string city string } func newPerson(name string, age int, nation, city string) *person { return &person{ name: name, age: age, loc: &location{ nation: nation, city: city, }, } } func SortStructMain() { // Integer 정렬 numbers := []int{1, 3, 4, 2, 5} slice := sort.IntSl..
[Go] Linked List 구현
·
Go
package datastruct import ( "fmt" ) type LinkedList struct { Head *Node Tail *Node Size int } type Node struct { Data any Next *Node } func NewLinkedList() *LinkedList { return &LinkedList{ Head: nil, Tail: nil, Size: 0, } } func newNode(value any) *Node { return &Node{ Data: value, Next: nil, } } func (list *LinkedList) Lpush(value any) { node := newNode(value) if list.Head == nil { list.Head =..
[Go] Panic recover 하기
·
Go
package recovery import ( "errors" "fmt" ) func panicRecover() { defer func() { r := recover() fmt.Println("Recover panic: ", r) }() panic(errors.New("something is wrong...")) // unreachable // fmt.Println("panicRecover() is done.") } func RecoveryMain() { fmt.Println("START!") panicRecover() fmt.Print("RecoveryMain() is done.") } /* START! Recover panic: something is wrong... RecoveryMain() is ..
[Go] File 정보 확인
·
Go
Go File 정보 확인 package file import ( "fmt" "os" "runtime" "syscall" "time" ) const FILE_PATH = "data/big_data.txt" type myFile struct { file *os.File } func newMyFile(file *os.File) *myFile { f := myFile{ file: file, } return &f } func (f *myFile) showStat() { stat, err := f.file.Stat() if err != nil { panic(err) } /* type FileInfo interface { Name() string // base name of the file Size() int64 /..
[Go] variable type별 printf format
·
Go
func main() { var num1 int = 10 var num2 float32 = 3.2 var num3 complex64 = 2.5 + 8.1i var s string = "Hello, world!" var b bool = true var a []int = []int{1, 2, 3} var m map[string]int = map[string]int{"Hello": 1} var p *int = new(int) type Data struct{ a, b int } var data Data = Data{1, 2} var i interface{} = 1 fmt.Printf("정수: %d\n", num1) // 정수: 10 fmt.Printf("실수: %f\n", num2) // 실수: 3.2 fmt...
[Go] 대용량 파일 chunk 단위로 나누기
·
Go
Go lang으로 대용량 파일 chunk 단위로 나누기 Go lang으로 대용량 파일에 대해서 chunk 단위로 나누어 보자. 나누기 위해서 우선 대용량 파일을 생성한 후 나누기를 진행 할 것이다. 대용량 파일 생성 파일 나누기 1. 대용량 파일 생성 package main import ( "fmt" "math" "os" "runtime" "strconv" "time" ) const MAX_CONCURRENT_JOB = 10 const NUMBER_OF_UNORDERED = 100000000 const BIG_DATA_ROOT = "data" const BIG_DATA_FILE_PATH = "data/big_data.txt" const FILE_CHUNK_SIZE = 10 * (1
Python 에서 go 함수 사용 하는 방법
·
Python/Python
Python With Go Python 은 쉽고, 깔금하고, 독립적이며, 짧은 시간안에 개발을 할 수 있으며, 수많은 라이브러리들을 사용 할 수 있다는 점에서 좋은 언어 이다. 다만, 파이썬의 장점의 모든 것들은 속도 라는 대가를 가진다. (numpy 같은 c 라이브러리 제외 하고는...) pypy 나 pyc 등에 속도 향상을 대체도 있지만 실제 사용해보면 현실은 녹록치 않다. Go to Python Go 에서는 Go 를 C에 연결을 혹은 C를 Go에 연결을 도와주는 라이브러리를 제공한다. https://golang.org/cmd/cgo/ Python 에서는 C 모듈을 가져와서 사용 할 수있는 기능이 있기 때문에 Go도 마찬가지로 사용이 가능하다. Go .so 파일 만들기 import "C" 와 사용 할..
Golang
·
Go
Go Go 소개 2007년 구글에서 개발을 시작하여 2012년 GO 버젼 1.0을 완성. (현재 1.17 까지 realase) 디자인은 로버트 그리즈머, 롭 파이크, 케네스 톰슨 (대학교 전공 서적에 나오는 사람, C언어 만든 사람) 이 진행 Using at Use cases https://go.dev/solutions/#case-studies 특징 컴파일 언어 정적 타이핑 언어 함수형 언어 빠른 속도 일차적 개발 목적은 시스템 프로그래밍 직접 개발하면서 느낀 장점과 단점 장점 Go 는 문법이 매우 간단하고 배우기 쉽다 문법은 C++, Java, Python 장단점 섞어 놓은 느낌 동시성 기능 구현 쉬움 배포 Architecture 관점에서 진짜 진짜 쉬운 배포 모든 Go 프로젝트는 누가 개발하든 모두 ..