Skip to content

Instantly share code, notes, and snippets.

@ignazioc
Last active June 14, 2018 23:00
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 ignazioc/28a5339cfeecfc5f01ebeecaa3e13584 to your computer and use it in GitHub Desktop.
Save ignazioc/28a5339cfeecfc5f01ebeecaa3e13584 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
import XCTest
class UserManagerTests: XCTestCase {
func testConvertToHtml() {
self.measure {
let htmlString = String.init(repeating: "<p>I am normal</p><b>asdfasd</b><i>asdfasdfa</i>", count: 1000)
_ = htmlString.convertHtml()
}
}
}
extension String {
func convertHtml() -> NSAttributedString {
let modifiedFont = String(format:"<span style=\"font-family: '-apple-system', 'HelveticaNeue'; font-size: 17\">%@</span>", self)
let data = modifiedFont.data(using: .utf8)!
return try! NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)
}
}
UserManagerTests.defaultTestSuite.run()
@ignazioc
Copy link
Author

Test Case '-[__lldb_expr_61.UserManagerTests testConvertToHtml]' measured [Time, seconds] average: 0.928, relative standard deviation: 3.961%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment