[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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
57 | Develop |
[api] 인스타그램 API Access_Token 발급 방법 (Instagram API)
3 ![]() |
hooni | 2018.04.05 | 7760 |
56 | Develop |
[php] Connect to Firebase Console in Laravel
![]() |
hooni | 2018.05.09 | 3234 |
55 | Develop |
[PHP] Mac OS에서 PHP 7 설치하기
![]() |
hooni | 2018.05.11 | 5056 |
54 | Develop |
[ios] Requesting Location Permissions in iOS
![]() |
hooni | 2018.08.18 | 1744 |
53 | System/OS |
서버 확장을 위한 두 가지 방법
![]() |
hooni | 2018.08.29 | 2278 |
52 | System/OS |
Mac에서 Node.js 설치하기
![]() |
hooni | 2018.09.28 | 4346 |
51 | Develop | [ios] Swift 4 String, Date, DateFormatter 예제 | hooni | 2018.10.18 | 1520 |
50 | Develop | [ios] APNS, Remote Push 수신 시점에서 앱의 3가지 실행 상태 | hooni | 2018.10.19 | 1100 |
49 | Develop | [ios] APNS, Remote Push 사용자가 수신을 동의했는지 확인하기 | hooni | 2018.10.19 | 1377 |
48 | Develop | [ios] Swift 4 Singleton inheritance | hooni | 2018.10.31 | 1695 |
47 | Develop |
[ios] Swift 4 Dictionary 사용하기
![]() |
hooni | 2018.11.29 | 2133 |
46 | Develop |
[ios] Locale Identifiers
![]() |
hooni | 2018.11.29 | 1747 |