Develop
2021.09.14 06:05

[swift] 실행시간 측정하기

Views 670 Votes 0 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. [vbs] CD롬 뱉는 스크립트..

    Date2003.04.23 CategoryDevelop Byhooni Views11699
    Read More
  2. [unix] 유닉스 명령에 메타문자 사용

    Date2014.02.19 CategoryDevelop Byhooni Views11247
    Read More
  3. [unix] 유닉스 csh에서 환경변수 등록

    Date2003.04.23 CategorySystem/OS Byhooni Views11697
    Read More
  4. [unix] 쉘 스크립트 예제 모음

    Date2003.04.23 CategoryDevelop Byhooni Views14949
    Read More
  5. [unix] 로그파일 정리 쉘스크립트

    Date2014.02.19 CategoryDevelop Byhooni Views10801
    Read More
  6. [unix] 날짜 관련 쉘 명령어 (특정일 또는 +-시간, 날짜 계산된 값)

    Date2013.04.23 CategoryDevelop Byhooni Views14801
    Read More
  7. [unix] SUN Solaris 싱글모드.. ㅡ,.ㅡ;

    Date2003.04.23 CategorySystem/OS Byhooni Views11991
    Read More
  8. [unix] Java 애플릿용 HTML 자동 생성

    Date2014.02.19 CategoryDevelop Byhooni Views8212
    Read More
  9. [unix] AIX쉘 초기 파일 (.cshrc)

    Date2013.04.23 CategorySystem/OS Byhooni Views10291
    Read More
  10. [ubuntu] 우분투 18.04에 PHP5 설치하기

    Date2020.11.14 CategoryDevelop Byhooni Views936
    Read More
  11. [switch] 시스코 카탈리스트(Cisco Catalyst) 기본 설정

    Date2013.04.23 CategorySystem/OS Byhooni Views17496
    Read More
  12. [switch] 시스코 카탈리스트(Cisco Catalyst) 2950 미러링 설정

    Date2013.04.23 CategoryDevelop Byhooni Views11386
    Read More
  13. [switch] 시스코 스위치(catalyst 2950) telnet 설정

    Date2013.04.23 CategoryDevelop Byhooni Views11269
    Read More
  14. [switch] 시스코 스위치 관리자 암호 초기화 방법

    Date2013.04.23 CategorySystem/OS Byhooni Views17186
    Read More
  15. [swift] 실행시간 측정하기

    Date2021.09.14 CategoryDevelop Byhooni Views670
    Read More
  16. [swift] UIView에서 subview 찾기

    Date2022.12.09 CategoryDevelop Byhooni Views1627
    Read More
Board Pagination Prev 1 ... 7 8 9 10 11 ... 74 Next
/ 74