Jounce / Surge

A Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

suggestions on delta time comparison using surge vs not.

johndpope opened this issue · comments

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.

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

    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)