All Projects → ifndefgt → Structvsclassperformance

ifndefgt / Structvsclassperformance

Licence: mit
POC for my Medium article

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Structvsclassperformance

Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+4518.18%)
Mutual labels:  struct, class
Struct2ts
Generate Typescript classes/interfaces out of Go structs
Stars: ✭ 116 (+954.55%)
Mutual labels:  struct, class
Node Servertiming
📊 Generate Server-Timing headers interactively in NodeJS
Stars: ✭ 19 (+72.73%)
Mutual labels:  performance
Image Actions
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Stars: ✭ 844 (+7572.73%)
Mutual labels:  performance
Fast Elixir
💨 Writing Fast Elixir 😍 -- Collect Common Elixir idioms.
Stars: ✭ 924 (+8300%)
Mutual labels:  performance
Cve 2020 10199 cve 2020 10204
CVE-2020-10199、CVE-2020-10204漏洞一键检测工具,图形化界面。CVE-2020-10199 and CVE-2020-10204 Vul Tool with GUI.
Stars: ✭ 20 (+81.82%)
Mutual labels:  poc
Stackext
Header-only C++ library for working with an extended stack
Stars: ✭ 27 (+145.45%)
Mutual labels:  performance
Walle
iOS Application performance monitoring
Stars: ✭ 19 (+72.73%)
Mutual labels:  performance
Mcdowell Cv
A Nice-looking CV template made into LaTeX
Stars: ✭ 855 (+7672.73%)
Mutual labels:  class
Browser Perf
Performance Metrics for Web Browsers
Stars: ✭ 930 (+8354.55%)
Mutual labels:  performance
Wordpress Rest Cache
WordPress Plugin to lazy cache HTTP requests in database and update via cron.
Stars: ✭ 8 (-27.27%)
Mutual labels:  performance
Listpool
Optimized allocation free implementation of IList using ArrayPool.
Stars: ✭ 25 (+127.27%)
Mutual labels:  performance
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (+100%)
Mutual labels:  struct
Performance
In diesem Repository befinden sich Projekte rund um das Thema Performanz.
Stars: ✭ 7 (-36.36%)
Mutual labels:  performance
Lazycache
An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
Stars: ✭ 901 (+8090.91%)
Mutual labels:  performance
Lozad.js
🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
Stars: ✭ 6,932 (+62918.18%)
Mutual labels:  performance
Koa Dec Router
An ES6 decorator + class based router, support inherit, override, priority, auto load controllers, etc.
Stars: ✭ 19 (+72.73%)
Mutual labels:  class
Go Concurrency Test
Test the performance of Go's concurrency structures
Stars: ✭ 24 (+118.18%)
Mutual labels:  performance
Watimage
🖼 PHP image manipulation class
Stars: ✭ 25 (+127.27%)
Mutual labels:  class
V8 Bailout Reasons
🔧 A list of Crankshaft bailout reasons with examples
Stars: ✭ 861 (+7727.27%)
Mutual labels:  performance

Struct vs Class Performance

This is a POC for my Medium article Stop Using Structs!! which compares performance characteristics of structs and classes, with a view to show where structs are misused and contain other reference types.

Warning

The article and POC was published for Swift version 4.0 and this POC is valid for Swift 4.0 and -very likely- previous versions. But with Swift 4.1 and 4.2 Apple changed calling convention and ownership model and these changes directly effect language's performance characteristics.

Therefore the results of this POC may vary and is not perfectly valid for Swift versions after 4.0.

Results

I tested each configuration with 100 iterations, results are averages in milliseconds, smaller is better :)

Optimization Level Class Struct Ratio
-Onone (unoptimized) 47926 89411 ~1.86x
-O (single file optimization) 5981 16503 ~2.76x
-O -whole-module-optimization 372 24809 ~67x

Requirements

  • Xcode 9.0
  • Swift 4.0

Running

xcrun -sdk macosx swiftc -O -whole-module-optimization StructvsClassPerformance.swift
./StructvsClassPerformance

License

Licensed under the terms of the MIT license. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].