Coder Social home page Coder Social logo

dbios's Introduction

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.

dbios's People

Contributors

sofbix avatar

Stargazers

Nikolai Eremenko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.