[swift] 실행시간 측정하기
start, end 구해서 end-start
func evaluateProblem(problemNumber: Int, problemBlock: () -> Int) -> Answer
{
print("Evaluating problem \(problemNumber)")
let start = DispatchTime.now() // <<<<< Start time
let myGuess = problemBlock()
let end = DispatchTime.now() // <<<<< End time
let theAnswer = self.checkAnswer(answerNum: "\(problemNumber)", guess: myGuess)
let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds // <<<<< Difference in nano seconds (UInt64)
let timeInterval = Double(nanoTime) / 1_000_000_000 // Technically could overflow for long running test
print("Time to evaluate problem \(problemNumber): \(timeInterval) seconds")
return theAnswer
}
출처: https://stackoverflow.com/questions/24755558/measure-elapsed-time-in-swift
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1149 | System/OS |
[mac] VirtualBox 실행 스크립트와 bash_profile 설정
![]() |
hooni | 2020.07.08 | 1162 |
1148 | System/OS | [linux] wget 명령 사용 예제 | hooni | 2020.05.26 | 1581 |
1147 | System/OS | [linux] The Ultimate Wget Download Guide With 15 Awesome Examples | hooni | 2020.05.26 | 969 |
1146 | Develop | [sh] 쉘스크립트 if 비교 연산 | hooni | 2020.05.26 | 60841 |
1145 | Develop |
[sh] html 안에 있는 img 다운 받는 쉘 스크립트
![]() |
hooni | 2020.05.26 | 743 |
1144 | Develop |
[ios] Start developing your navigation app for CarPlay without enrollment
![]() |
hooni | 2020.02.22 | 125121 |
1143 | System/OS |
Configure Postfix to Use Gmail SMTP on Ubuntu 18.04
![]() |
hooni | 2020.02.07 | 1479 |
1142 | System/OS |
RPA란? 어디에 어떻게 쓰이고 누가 만드나?
![]() |
hooni | 2020.01.28 | 1488 |
1141 | Develop |
[php] 3 Ways to Detect Mobile or Desktop in PHP
![]() |
hooni | 2020.01.28 | 3961 |
1140 | Develop | 자주 쓰는 Docker 명령어 alias | hooni | 2020.01.10 | 270670 |
1139 | Develop | [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) | hooni | 2019.12.06 | 1806 |
1138 | System/OS |
SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
![]() |
hooni | 2019.11.22 | 1523 |