Last active
June 14, 2018 23:00
-
-
Save ignazioc/28a5339cfeecfc5f01ebeecaa3e13584 to your computer and use it in GitHub Desktop.
This file contains 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
//: 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test Case '-[__lldb_expr_61.UserManagerTests testConvertToHtml]' measured [Time, seconds] average: 0.928, relative standard deviation: 3.961%