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
#!/bin/bash | |
# Define colors & styles for outputs | |
# ---------------------------------- | |
red='\033[1;31m' | |
green='\033[32m' | |
bold='\033[1m' | |
italic='\033[2;3m' | |
reset='\033[0m' |
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
func measure(closure: (()->Void)) { | |
let start = Date() | |
closure() | |
let interval = Date().timeIntervalSince(start) | |
print(interval) | |
} | |
extension Int { | |
var ascii: [UInt8] { |
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
// Results | |
// Range vs Prefix&Suffix | |
// 5.88606303930283 vs 9.89196902513504 - Manipulating Array | |
// 5.65134799480438 vs 5.69769901037216 - Manipulating String | |
func measure(closure: (()->Void)) { | |
let start = Date() | |
closure() | |
let interval = Date().timeIntervalSince(start) | |
print(interval) |
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
/** | |
Measuring the performance of reduce compared to joined and map+joined. | |
Spoiler: map+joined way more faster!!! | |
Try this code in a .playground file if you want. | |
*/ | |
func measure(closure: (()->Void)) { | |
let start = Date() | |
closure() |