[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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
37 | Develop | [ios] Crashlytics, Fabfic 설치/설정 | hooni | 2016.07.21 | 743 |
36 | Develop |
[Javascript][Ajax] 자바스크립트 강의 산출물
![]() |
hooni | 2019.10.05 | 715 |
35 | Develop | [android] Android N requires the IDE to be running with Java 1.8 or later 오류 | hooni | 2016.08.30 | 712 |
34 | Develop |
[ios] 비디오,네트워크,소셜로그인 테스트
![]() |
hooni | 2017.04.04 | 706 |
» | Develop | [swift] 실행시간 측정하기 | hooni | 2021.09.14 | 699 |
32 | Develop |
[matlab] 정보은닉 스테가노그래피(Steganography) 수업
![]() |
hooni | 2016.10.03 | 698 |
31 | Develop | Aspect Oriented Programming in Objective-C | hooni | 2015.05.18 | 694 |
30 | Develop |
정리할 자료.
![]() |
hooni | 2015.07.02 | 693 |
29 | Develop | [js] Text 값을 클립보드에 복사하기 | hooni | 2020.10.10 | 690 |
28 | Develop | [ios] WWDC 2015 샘플 소스 코드 통합파일 | hooni | 2015.07.20 | 689 |
27 | Develop | [ios] 여러 버전의 Xcode 사용하기 | hooni | 2022.05.28 | 686 |
26 | Develop |
[ios] Touch ID 적용 샘플 코드 (예제)
![]() |
hooni | 2015.02.23 | 678 |