Hub of examples and tests DataBase frameworks wich used by iOS developers. It needs for compare code, features and performance of different frameworks.
SwiftData Realm Fluent CoreStore
I have implemented a DBiOS app for performance tets that compiles from target PerformanceAllDb
:
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:
for i in 1...iterationCount{
try await query(i)
}
try await withThrowingTaskGroup(of: Void.self) { group in
for i in 1...iterationCount{
group.addTask {
try await query(i)
}
}
try await group.waitForAll()
}
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
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.
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.
MIT license. See LICENSE for details.