Created
June 29, 2018 08:09
-
-
Save yusuke024/41a4695789d32156c069369ccfb566c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
final class Static { | |
func a() { 1 + 1 } | |
func b() { a() } | |
func c() { b() } | |
} | |
class Dynamic { | |
func a() { 1 + 1 } | |
func b() { a() } | |
func c() { b() } | |
} | |
class Dynamic1: Dynamic { } | |
class Dynamic2: Dynamic1 { } | |
class Dynamic3: Dynamic2 { | |
override func a() { 1 + 1 } | |
override func b() { a() } | |
override func c() { b() } | |
} | |
class MyTestCase: XCTestCase { | |
func testStatic() { | |
let s = Static() | |
measure { | |
for _ in 0..<10000 { | |
s.c() | |
} | |
} | |
} | |
func testDynamic() { | |
let d: Dynamic | |
d = Dynamic3() | |
measure { | |
for _ in 0..<10000 { | |
d.c() | |
} | |
} | |
} | |
} | |
MyTestCase.defaultTestSuite.run() // Swift 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment