Last active
June 5, 2018 07:19
-
-
Save oleghnidets/a1fa0c2f4b497929965e91916214de72 to your computer and use it in GitHub Desktop.
Test concatenation
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
// Created by Oleg H. on 5/17/18. | |
// Copyright © 2018 Oleg H. All rights reserved. | |
// | |
import XCTest | |
let count = 150000 | |
/* | |
Plust operator is faster. | |
*/ | |
class StringsTestTests: XCTestCase { | |
func testInterpolation() { | |
var result = "" | |
measure { | |
let foo = "foo" | |
let bar = "bar" | |
for _ in 0 ..< count { | |
result = "\(foo)\(bar)" | |
} | |
} | |
print(result) | |
} | |
func testPlusOperator() { | |
var result = "" | |
measure { | |
let foo = "foo" | |
let bar = "bar" | |
for _ in 0 ..< count { | |
result = foo + bar | |
} | |
} | |
print(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment