Skip to content

Instantly share code, notes, and snippets.

View danieltmbr's full-sized avatar

Daniel Tombor danieltmbr

  • London, United Kingdom
View GitHub Profile
#!/bin/bash
# Define colors & styles for outputs
# ----------------------------------
red='\033[1;31m'
green='\033[32m'
bold='\033[1m'
italic='\033[2;3m'
reset='\033[0m'
@danieltmbr
danieltmbr / bytes to string
Last active September 29, 2017 10:06
Swift integer & byte array to ascii string convert performance test
func measure(closure: (()->Void)) {
let start = Date()
closure()
let interval = Date().timeIntervalSince(start)
print(interval)
}
extension Int {
var ascii: [UInt8] {
@danieltmbr
danieltmbr / subscript-vs-fixes.swift
Last active September 21, 2017 13:28
Mesure performance of ranges compared to suffixing and prefixing
// 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)
@danieltmbr
danieltmbr / map-joined-reduce.swift
Last active September 21, 2017 09:57
Compare performance reduce to joined & map+joined
/**
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()