Contents

Develop
2021.09.14 06:05

[swift] 실행시간 측정하기

조회 수 831 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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





?

  1. [link] 유용한 사이트 링크.

    Date2013.08.19 CategoryEtc Byhooni Views72521
    Read More
  2. [linux] /etc/fstab 설정 방법.. ㅋㅋ

    Date2013.04.23 CategorySystem/OS Byhooni Views12153
    Read More
  3. [linux] apache, php, jsp 환경설정하기..

    Date2003.04.23 CategorySystem/OS Byhooni Views15305
    Read More
  4. [linux] APM(apache, php, mysql) + gd 설치순서..

    Date2003.04.23 CategorySystem/OS Byhooni Views18936
    Read More
  5. [linux] awk 명령어

    Date2014.03.11 CategorySystem/OS Byhooni Views5035
    Read More
  6. [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..."

    Date2014.04.05 CategorySystem/OS Byhooni Views4961
    Read More
  7. [linux] CentOS 6.x Cati 설치 (yum)

    Date2014.01.17 CategorySystem/OS Byhooni Views48660
    Read More
  8. [linux] CentOS Apache Httpd에 https 적용

    Date2014.03.05 CategorySystem/OS Byhooni Views4587
    Read More
  9. [linux] CentOS Apache 웹서버에 HTTPS 적용

    Date2015.10.23 CategoryDevelop Byhooni Views914
    Read More
  10. [linux] CentOS 에 APM 설치하기

    Date2015.01.02 CategorySystem/OS Byhooni Views1909
    Read More
  11. [linux] CentOS 터미널 언어 설정(한글/영어)

    Date2013.12.22 CategorySystem/OS Byhooni Views18625
    Read More
  12. [linux] crond 사용법.. ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views7274
    Read More
Board Pagination Prev 1 ... 60 61 62 63 64 65 66 67 68 69 ... 98 Next
/ 98