Skip to content

Instantly share code, notes, and snippets.

@oleghnidets
Last active June 5, 2018 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleghnidets/a1fa0c2f4b497929965e91916214de72 to your computer and use it in GitHub Desktop.
Save oleghnidets/a1fa0c2f4b497929965e91916214de72 to your computer and use it in GitHub Desktop.
Test concatenation
// 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