[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
-
[link] 유용한 사이트 링크.
-
[linux] /etc/fstab 설정 방법.. ㅋㅋ
-
[linux] apache, php, jsp 환경설정하기..
-
[linux] APM(apache, php, mysql) + gd 설치순서..
-
[linux] awk 명령어
-
[linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..."
-
[linux] CentOS 6.x Cati 설치 (yum)
-
[linux] CentOS Apache Httpd에 https 적용
-
[linux] CentOS Apache 웹서버에 HTTPS 적용
-
[linux] CentOS 에 APM 설치하기
-
[linux] CentOS 터미널 언어 설정(한글/영어)
-
[linux] crond 사용법.. ㅋㅋ