Contents

Develop
2021.09.14 06:05

[swift] 실행시간 측정하기

Views 831 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

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. [unix] 로그파일 정리 쉘스크립트

  2. [unix] 날짜 관련 쉘 명령어 (특정일 또는 +-시간, 날짜 계산된 값)

  3. [unix] SUN Solaris 싱글모드.. ㅡ,.ㅡ;

  4. [unix] Java 애플릿용 HTML 자동 생성

  5. [unix] AIX쉘 초기 파일 (.cshrc)

  6. [ubuntu] 우분투 18.04에 PHP5 설치하기

  7. [switch] 시스코 카탈리스트(Cisco Catalyst) 기본 설정

  8. [switch] 시스코 카탈리스트(Cisco Catalyst) 2950 미러링 설정

  9. [switch] 시스코 스위치(catalyst 2950) telnet 설정

  10. [switch] 시스코 스위치 관리자 암호 초기화 방법

  11. [swift] 실행시간 측정하기

  12. [swift] UIView에서 subview 찾기

Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 ... 98 Next
/ 98