Skip to content

Instantly share code, notes, and snippets.

View ManWithBear's full-sized avatar
🐻
Bear with it

Denis Bogomolov ManWithBear

🐻
Bear with it
View GitHub Profile
@ManWithBear
ManWithBear / projectInfo.stencil
Created December 3, 2019 15:27
Collect information about data types in project using Sourcery
enums {{ types.enums.count }}
protocols {{ types.protocols.count }}
classes {{ types.classes.count }}
structs {{ types.structs.count }}
//
// Copyright © 2017 Square, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
#!/bin/zsh
# For each framework in current folder list all imported frameworks.
# `find_imports_directories_to_skip.txt` contains list of directories to ignore (e.g. xcodeproj)
# `find_imports_imports_to_skip.txt` contains list of imported frameworks that should be removed from output (e.g. UIKit)
DIRECTORIES_TO_SKIP=$(cat find_imports_directories_to_skip.txt)
for FORFramework in $(ls -d -- */) # itterate over all directories in current folder
do
if [[ $DIRECTORIES_TO_SKIP =~ "${FORFramework}" ]]; then
@ManWithBear
ManWithBear / libdispatch-efficiency-tips.md
Created January 23, 2023 23: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