[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
-
[unix] 로그파일 정리 쉘스크립트
-
[unix] 날짜 관련 쉘 명령어 (특정일 또는 +-시간, 날짜 계산된 값)
-
[unix] SUN Solaris 싱글모드.. ㅡ,.ㅡ;
-
[unix] Java 애플릿용 HTML 자동 생성
-
[unix] AIX쉘 초기 파일 (.cshrc)
-
[ubuntu] 우분투 18.04에 PHP5 설치하기
-
[switch] 시스코 카탈리스트(Cisco Catalyst) 기본 설정
-
[switch] 시스코 카탈리스트(Cisco Catalyst) 2950 미러링 설정
-
[switch] 시스코 스위치(catalyst 2950) telnet 설정
-
[switch] 시스코 스위치 관리자 암호 초기화 방법
-
[swift] 실행시간 측정하기
-
[swift] UIView에서 subview 찾기