Skip to content
/ DBiOS Public

Hub of examples and tests DataBase frameworks wich used by iOS developers

License

Notifications You must be signed in to change notification settings

sofbix/DBiOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBiOS

What is it?

Hub of examples and tests DataBase frameworks wich used by iOS developers. It needs for compare code, features and performance of different frameworks.

What frameworks to compare:

SwiftData SwiftData Realm Realm Fluent Fluent CoreStore CoreStore

Than to test

I have implemented a DBiOS app for performance tets that compiles from target PerformanceAllDb:

Screen

Async (concurrent requests)

Usually, mobile applications execute queries serially, from one or more Threads. But test can emulate concurrent execution with high load to Processor. The app uses Swift Concurrency technology to test multithreaded operation. What is difference:

Serial

    for i in 1...iterationCount{
        try await query(i)
    }

Concurrent

    try await withThrowingTaskGroup(of: Void.self) { group in
        for i in 1...iterationCount{
            group.addTask {
                try await query(i)
            }
        }
        try await group.waitForAll()
    }

How to add a new Framework

First clone the repository and create a new module in Modules directory. Then you need to implement 4 classes from Container.swift:

  • DatabaseProtocol needed for init DB, migration and get database context for next class
  • DatabaseQueryProtocol needed for calling queries from DB
  • TodoProtocol - Todo entity for DB
  • TodoGroupProtocol - TodoGroup entity for DB

Test Application with your framework

In next you'll just need to make target in the project with the next init code:

import SwiftUI
import CoreModule
import YourModule

@main
struct SwiftDataDBApp: App {
    var body: some Scene {
        WindowGroup {
            StartView(
                db: YourModule.DatabaseManager.shared,
                dbQuery: YourModule.DatabaseQuery(databaseManager: YourModule.DatabaseManager.shared)
            )
        }
    }
}

Add CoreModule and YourModule to Build Phase/Link Binaries then you can test your framework in seporated application.

Compare Application with yours and all other frameworks

Add YourModule from previous step to PerformanceAllDb target and add to ContentView.swift next tab:

    PerformanceFacadeView(
        name: "YourDB", 
        db: YourModule.DatabaseManager.shared, 
        dbQuery: YourModule.DatabaseQuery(databaseManager: YourModule.DatabaseManager.shared)
    )
    .tabItem{
        Image("YourDB")
        Text("YourDB")
    }
    .tag(newIndex)

And you can share your framework performance with others. Don't forget to make a Pull to Request to share with the rest of the community.

License

MIT license. See LICENSE for details.

About

Hub of examples and tests DataBase frameworks wich used by iOS developers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages