Skip to content

Instantly share code, notes, and snippets.

@tsanto
tsanto / libdispatch-efficiency-tips.md
Created November 27, 2020 21:15 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
@tsanto
tsanto / XCTestCaseExtensions.swift
Created April 10, 2020 00:19 — forked from AvdLee/XCTestCaseExtensions.swift
This extension should make it fairly easy to test your Share Extension. Read more about it here: https://www.avanderlee.com/swift/ui-test-share-extension/
//
// XCTestCaseExtensions.swift
//
// Useful extension to UI Test the Share Extension of apps.
//
//
// Created by Antoine van der Lee on 18/05/2018.
// Copyright © 2018. All rights reserved.
//
@tsanto
tsanto / Deploying.yml
Created January 10, 2020 23:17
Files used in this repo @/tsanto/Calculator-github-actions to deploy an iOS app.
name: Deploying
on:
push:
branches:
- master
jobs:
deploy:
name: Deploying to Testflight
runs-on: macOS-latest
steps:
@tsanto
tsanto / Testing.yml
Last active January 10, 2020 21:31
Files used in this repo @/tsanto/Calculator-github-actions to test an iOS app and Swift Package.
name: Testing
on:
pull_request:
branches:
- master
jobs:
test:
name: Testing Swift Package and iOS app
runs-on: macOS-latest
steps:

Keybase proof

I hereby claim:

  • I am tsanto on github.
  • I am tsanto (https://keybase.io/tsanto) on keybase.
  • I have a public key ASAEVHwL1MJJEyOmO9rP3EVI3N436Tg9HmIENAMsXS3ejQo

To claim this, I am signing this object: