Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestions on delta time comparison using surge vs not. #87

Closed
johndpope opened this issue Sep 4, 2018 · 2 comments
Closed

suggestions on delta time comparison using surge vs not. #87

johndpope opened this issue Sep 4, 2018 · 2 comments

Comments

@johndpope
Copy link

is there a better way than using nslog ? are there any performance reports looked into?
looking for a report or mode to demonstrate performance gains.

@johndpope
Copy link
Author

found this

import QuartzCore

func executionTimeInterval(block: () -> ()) -> CFTimeInterval {
    let start = CACurrentMediaTime()
    block();
    let end = CACurrentMediaTime()
    return end - start
}


// DEMO (paste all this into a playground)
// Non-memoized Fibonacci generator
func fib(n: Int) -> Int {
    assert(n >= 0)
    switch n {
    case 0, 1: return 1
    default:   return fib(n-1) + fib(n-2)
    }
}

let fib8 = executionTimeInterval {
    let x = fib(8)
    print("fib(8) = \(x)")
}

let fib10 = executionTimeInterval {
    let x = fib(10)
    print("fib(10) = \(x)")
}

let fib12 = executionTimeInterval {
    let x = fib(12)
    print("fib(12) = \(x)")
}

https://gist.github.com/johndpope/d22970b54f6c6cde4d37cc3376f61a18

@johndpope
Copy link
Author

    let start = DispatchTime.now()
 // your code here
    let end = DispatchTime.now()
    let time = Double(end.uptimeNanoseconds - start.uptimeNanoseconds)/Double(1_000_000_000)
    print(time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant