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
// Executed with optimization -Os on a MacBook Pro (15-inch, 2017) 2,8 GHz Intel Core i7 | |
class StringPerformanceTest: XCTestCase { | |
// Takes in average 0.075 secs | |
func testPerformanceOfUTF8View() { | |
let data = "_cqeFf~cjVf@p@fA}AtAoB`ArAx@hA`GbIvDiFv@gAh@t@X\\|@z@`@Z\\Xf@Vf@VpA\\tATJ@NBBkC".data(using: .utf8)! | |
let string = String(decoding: data, as: UTF8.self) | |
measure { | |
for _ in 0...10_000 { | |
_ = string.utf8.reduce(into: 0, { count, _ in count += 1 }) |
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
import Foundation | |
struct User { | |
let name: String | |
let age: Int | |
} | |
struct Car { | |
let color: String | |
} |
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
// | |
// LOOCryptString.h | |
// | |
// Created by Marcin Swiderski on 6/8/12. | |
// Copyright (c) 2012 Marcin Swiderski. All rights reserved. | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |