Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift SDK & Sample #1621

Merged
merged 157 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
1d2b250
Moved iOS SDK from example to src
NumericalMax Dec 16, 2022
ebde5eb
Merge pull request #1 from NumericalMax/setup-ios-sdk
NumericalMax Dec 16, 2022
ecc3f05
Moving iOS-SDK reference
NumericalMax Dec 16, 2022
125745e
Merge pull request #2 from NumericalMax/move-reference-ios-example
NumericalMax Dec 16, 2022
a9f4869
upgrade transport proto to flower 1.0 and change class names
Dec 16, 2022
9d31011
upgrade transport proto to flower 1.0 and change class names
Dec 16, 2022
6828449
upgrade transport proto to flower 1.0 and change class names
Dec 16, 2022
576594d
Merge pull request #3 from NumericalMax/add-missing-protobuf
danielnugraha Dec 16, 2022
67534f9
remove duplicate code for server and adapt config parameter
Dec 16, 2022
2915593
add newline at end of code
Dec 16, 2022
c4b2458
add pyproject.toml for example/ios server and update shell command in…
Dec 17, 2022
c55a9e3
update shell command in readme
Dec 17, 2022
8cb4472
added supported platform (with version)
weinhuber Dec 19, 2022
8651ee5
Lowered iOS version requirement
weinhuber Dec 19, 2022
f64709f
added progressview while processing and refactored some states
weinhuber Dec 23, 2022
59a6d8c
Merge pull request #5 from NumericalMax/refactor/PackagePlatform
weinhuber Dec 23, 2022
d1df680
Merge pull request #4 from NumericalMax/adapt-server.py
NumericalMax Dec 24, 2022
ef0cbb2
disabled possibility to prepare test and train dataset simultaneously
weinhuber Dec 30, 2022
38f7563
Merge pull request #6 from NumericalMax/refactor/ContentView
weinhuber Dec 30, 2022
962ba3b
Added Status model
NumericalMax Jan 2, 2023
77d98fa
Adjusted function calls
NumericalMax Jan 2, 2023
7588a17
removed status argument
NumericalMax Jan 2, 2023
d37c7af
minor change
NumericalMax Jan 2, 2023
2f7239f
set default string for message
NumericalMax Jan 2, 2023
c727d5d
Extended Code and init status
NumericalMax Jan 2, 2023
1de5df1
Status conversion
NumericalMax Jan 2, 2023
50893fa
Renaming
NumericalMax Jan 2, 2023
360512f
adjusted example
NumericalMax Jan 2, 2023
d4bb67d
Merge branch 'main' into add-flwr-proto-status
NumericalMax Jan 2, 2023
3a96d1c
Merge pull request #7 from NumericalMax/add-flwr-proto-status
danielnugraha Jan 4, 2023
7aeceee
Removed file that shouldn't be tracked
NumericalMax Jan 10, 2023
8546bf0
Added iOS to gitignore
NumericalMax Jan 10, 2023
368684c
renaming
NumericalMax Jan 10, 2023
8ad40da
added blank app icon
NumericalMax Jan 10, 2023
25733cb
renamed file
NumericalMax Jan 10, 2023
d872a40
Merge pull request #9 from NumericalMax/rename
danielnugraha Jan 10, 2023
8c2c3b6
managing python call in a single thread
Jan 13, 2023
29eb90c
activate fl start button after dataset preparation
Jan 13, 2023
876ba1c
add exit gracefully to parameterconverter eventloopgroup
Jan 13, 2023
6ea78d2
Merge pull request #10 from NumericalMax/fix-gil-assertion-fail
danielnugraha Jan 13, 2023
11d9250
fix race condition by add flwrGRPC class and remove Start func
Jan 16, 2023
a6f73c8
move python finalize to flwrGRPC
Jan 16, 2023
7ff191c
add debug message for opening and closing python event loop group
Jan 16, 2023
68ada2b
move compile model to new section
Jan 16, 2023
ccc4977
Merge pull request #11 from NumericalMax/fix-race-condition
NumericalMax Jan 16, 2023
3809097
refactored close connection to public
weinhuber Jan 16, 2023
441611c
included parameter converter
NumericalMax Jan 16, 2023
78ff0bb
Added Unit Tests for Serde
NumericalMax Jan 16, 2023
5f4c4fd
indent
NumericalMax Jan 16, 2023
db9e419
minor change
NumericalMax Jan 16, 2023
d735bd2
implemented stop button
weinhuber Jan 18, 2023
0aa392f
added status conversion to tests
weinhuber Jan 18, 2023
c241eb2
Merge pull request #12 from NumericalMax/fix-race-condition
weinhuber Jan 19, 2023
d1d14d3
Added BenchmarkModel
weinhuber Jan 19, 2023
c6b7676
wrapped BenchmarkModel in Suite
weinhuber Jan 19, 2023
9dd1d93
added monitoring of connection
weinhuber Jan 19, 2023
439945c
added benchmarking
weinhuber Jan 19, 2023
9ab112b
share benchmarking files
weinhuber Jan 19, 2023
418e7bd
reverted count break
weinhuber Jan 19, 2023
439c98b
changed object structure of networksnapshot
weinhuber Jan 19, 2023
d3303bb
add state management and move coremlclient to package
Jan 20, 2023
b51d977
fix merge conflict
Jan 20, 2023
e629f52
add BenchmarkInterceptor
weinhuber Jan 22, 2023
20250ae
add additionalInterceptor
weinhuber Jan 22, 2023
e3cf730
passing BenchmarkInterceptor
weinhuber Jan 22, 2023
96f4675
add wrapper to expose information to client
weinhuber Jan 22, 2023
bc7ca5e
adapt interceptor to use additional client interceptor
weinhuber Jan 22, 2023
0811dc1
move suite to client
weinhuber Jan 22, 2023
e8a84bf
move to client and refactored network snapshots
weinhuber Jan 22, 2023
5b25666
implement custom client interceptor to benchmark application
weinhuber Jan 22, 2023
ee9bb2c
Merge pull request #13 from NumericalMax/add-state-management
weinhuber Jan 22, 2023
606c559
bugfix
weinhuber Jan 22, 2023
97c26ea
fix merge conflict
weinhuber Jan 22, 2023
286b819
adapt benchmark to new state model
weinhuber Jan 22, 2023
3a73f24
refactored client interceptor
weinhuber Jan 22, 2023
ed96feb
Merge pull request #14 from NumericalMax/benchmark
NumericalMax Jan 23, 2023
e0c12d4
Merge branch 'main' into unit-tests
NumericalMax Jan 23, 2023
a990619
added metadata
NumericalMax Jan 23, 2023
ef4c16f
Added Expected failures
NumericalMax Jan 23, 2023
5345f4f
updated product bundle identifier
NumericalMax Jan 24, 2023
8379b22
Merge pull request #15 from NumericalMax/unit-tests
weinhuber Jan 24, 2023
d255518
renaming additional interceptor and its protocol
weinhuber Jan 25, 2023
f6317ea
Merge pull request #16 from NumericalMax/refactor/Interceptor
NumericalMax Jan 26, 2023
adca126
Init Github Actions iOS
NumericalMax Jan 28, 2023
089f30f
updated github actions
NumericalMax Jan 28, 2023
beb9983
minor change
NumericalMax Jan 28, 2023
9d92b86
first draft readme
NumericalMax Jan 28, 2023
07fb5ce
Update README.md
NumericalMax Jan 28, 2023
cbcfa0c
Added dependencies
NumericalMax Jan 28, 2023
27b3767
deleted xcuserdata
NumericalMax Jan 28, 2023
1543c00
deleted commented code
NumericalMax Jan 28, 2023
0683513
added public enum for disconnect reason
NumericalMax Jan 28, 2023
2b4029e
Added disconnect reason as argument
NumericalMax Jan 28, 2023
ab838d7
adapted function call
NumericalMax Jan 28, 2023
5cf1692
Adapt Server for Benchmark
NumericalMax Jan 28, 2023
fcdd16b
unwrap optional value
NumericalMax Jan 28, 2023
36f06f6
Added test
NumericalMax Jan 28, 2023
0d77cba
added icon
NumericalMax Jan 29, 2023
bd0dbbf
precision display loss
NumericalMax Jan 29, 2023
0fd4cb8
removed unused comment
NumericalMax Jan 30, 2023
9d79d1b
added documentation comments
NumericalMax Jan 30, 2023
dae8157
added documentation
NumericalMax Jan 30, 2023
713f204
further documentation
NumericalMax Jan 30, 2023
5b4d170
Merge pull request #19 from NumericalMax/readme
NumericalMax Jan 31, 2023
61eb081
Merge pull request #18 from NumericalMax/server-return
NumericalMax Jan 31, 2023
0c36a2a
Merge pull request #20 from NumericalMax/abort-connection-reason
NumericalMax Jan 31, 2023
5875082
fix merge conflicts
Feb 1, 2023
7d21de5
Merge pull request #21 from NumericalMax/merge-adap-branch
danielnugraha Feb 1, 2023
2cda076
Merge branch 'main' into clean-up-ios
NumericalMax Feb 1, 2023
423f0d6
Merge pull request #22 from NumericalMax/clean-up-ios
NumericalMax Feb 1, 2023
594dce0
Merge branch 'main' into github-actions-ios
NumericalMax Feb 10, 2023
1ceded9
Create Package.resolved
NumericalMax Feb 10, 2023
be38eb8
adapted the documentation
NumericalMax Feb 10, 2023
620d9d6
adapted github actions
NumericalMax Feb 10, 2023
9343719
minor change
NumericalMax Feb 10, 2023
74022f5
minor change
NumericalMax Feb 10, 2023
fa893d3
Merge remote-tracking branch 'upstream/main' into merge-adap-flower
NumericalMax Feb 10, 2023
068c67d
adapted documentation
NumericalMax Feb 10, 2023
e15deea
adapted file name
NumericalMax Feb 10, 2023
3112e4a
Merge pull request #17 from NumericalMax/github-actions-ios
danielnugraha Feb 10, 2023
20f5462
Merge pull request #23 from NumericalMax/merge-adap-flower
NumericalMax Feb 10, 2023
ba6cd2f
Added Scenario Picker
NumericalMax Feb 15, 2023
1334f8c
Extendable Scenario Selection
NumericalMax Feb 15, 2023
1ec5f2b
cleaning
NumericalMax Feb 15, 2023
03ee985
adapted scnearios
NumericalMax Feb 16, 2023
0d0bec2
adapting to more scenarios + minor restructuring
NumericalMax Feb 16, 2023
c16c040
Added tracking of scenarios
NumericalMax Feb 16, 2023
b588fa6
Model generation
NumericalMax Feb 16, 2023
e548207
remove client-model
Feb 17, 2023
9cb4a11
remove client-model
Feb 17, 2023
ed294df
remove cifar10 dataloader
Feb 17, 2023
97a6757
remove cifar10 dataloaderreference
Feb 17, 2023
29f21d3
Merge pull request #25 from NumericalMax/remove-client-model
NumericalMax Feb 17, 2023
f973408
Merge remote-tracking branch 'upstream/main' into merge-from-adap
Feb 17, 2023
fec26d6
Merge pull request #26 from NumericalMax/merge-from-adap
danielnugraha Feb 17, 2023
90a8ab5
add changes to review
Feb 17, 2023
b76f093
Merge pull request #27 from NumericalMax/review-changes
danielnugraha Feb 17, 2023
e013ccb
minor change
NumericalMax Feb 27, 2023
d6fe078
Merge pull request #24 from NumericalMax/extend-benchmark-scenarios
NumericalMax Feb 27, 2023
6ac116e
added log to parameter
NumericalMax Mar 7, 2023
88efc2f
added logging
NumericalMax Mar 7, 2023
fe09b8b
Merge pull request #28 from NumericalMax/replace-print-with-log
NumericalMax Mar 17, 2023
18fa513
restrict test on src/swift
Mar 21, 2023
0329650
fix swift.yml
Mar 21, 2023
a03c781
Merge pull request #29 from NumericalMax/restrict-github-actions
NumericalMax Mar 21, 2023
f155c77
Update swift.yml
danielnugraha Mar 21, 2023
d329914
fix swift.yml
Mar 21, 2023
cf2e069
Update swift.yml
danielnugraha Mar 21, 2023
7de1452
Update swift.yml
danielnugraha Mar 21, 2023
5b902c7
Merge pull request #30 from NumericalMax/restrict-github-actions
NumericalMax Mar 21, 2023
c74a606
Merge remote-tracking branch 'upstream/main' into merge-main-to-fork
Mar 23, 2023
6027cd5
add space before main
Mar 23, 2023
ef0ea33
minor change
NumericalMax Mar 24, 2023
2bb2d7d
Merge branch 'main' into merge-main-to-fork
NumericalMax Mar 26, 2023
1efdb9a
Merge pull request #31 from NumericalMax/merge-main-to-fork
NumericalMax Mar 26, 2023
8faf0f8
Merge remote-tracking branch 'upstream/main' into merge-main-to-fork
Mar 27, 2023
cdb03b6
Merge pull request #32 from NumericalMax/merge-main-to-fork
NumericalMax Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Swift

on:
push:
branches: ['main']
paths: ['src/swift/**']
pull_request:
branches: ['main']
paths: ['src/swift/**']


jobs:
build:
defaults:
run:
working-directory: src/swift/flwr
name: test_swift
strategy:
matrix:
os: [macos-latest]
swift: ["5"]
runs-on: ${{ matrix.os }}
steps:
- uses: fwal/setup-swift@2040b795e5c453c3a05fcb8316496afc8a74f192
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v3
- name: Run tests
run: arch -x86_64 xcodebuild test -scheme flwr -destination 'platform=iOS Simulator,name=iPhone 14 Pro Max,OS=16.2'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ dmypy.json
# Poetry
poetry.lock
*.pkl

# iOS
xcuserdata/
danieljanes marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "21B5406C2865B14000185DEE"
BuildableName = "FLiOS.app"
BlueprintName = "FLiOS"
ReferencedContainer = "container:FLiOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "21B5406C2865B14000185DEE"
BuildableName = "FLiOS.app"
BlueprintName = "FLiOS"
ReferencedContainer = "container:FLiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "21B5406C2865B14000185DEE"
BuildableName = "FLiOS.app"
BlueprintName = "FLiOS"
ReferencedContainer = "container:FLiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -1,86 +1,103 @@
{
"images" : [
{
"filename" : "icon40.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "icon60.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "icon58.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "icon87.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"filename" : "icon80.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "icon120 1.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "icon120.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "icon180.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"filename" : "icon20.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"filename" : "icon40 1.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "icon29.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"filename" : "icon58 1.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "icon40 2.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"filename" : "icon80 1.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "icon152.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"filename" : "icon167.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"filename" : "icon1024.png",
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions examples/ios/FLiOS/Benchmark/BenchmarkInterceptor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// BenchmarkInterceptor.swift
// FLiOS
//
// Created by Christoph Weinhuber on 22.01.23.
//

import Foundation
import flwr

class BenchmarkInterceptor: InterceptorExtension {
let benchmarkSuite = BenchmarkSuite.shared

func receive(part: GRPCPartWrapper) {
switch part {

case .metadata(_):
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.received(size: "0 Bytes"), description: "Received headers"))

case let .message(content):
let size = NetworkSnapshot.calcSize(message: content)
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.received(size: size), description: "Received response"))

case .end(_, _):
benchmarkSuite.takeActionSnapshot(snapshot: ActionSnaptshot(action: "Response stream closed"))
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.received(size: "0 Bytes"), description: "Response stream closed"))
}

}


func send(part: GRPCPartWrapper) {
switch part {

case .metadata(_):
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.sent(size: "0 Bytes"), description: "Sent headers"))

case let .message(content):
let size = NetworkSnapshot.calcSize(message: content)
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.sent(size: size), description: "Sent request"))

case .end(_, _):
benchmarkSuite.takeNetworkSnaptshot(snapshot: NetworkSnapshot(type: NetworkAction.sent(size: "0 Bytes"), description: "Closing request stream"))

}
}
}
81 changes: 81 additions & 0 deletions examples/ios/FLiOS/Benchmark/BenchmarkModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// BenchmarkModel.swift
//
//
// Created by Christoph Weinhuber on 10.01.23.
//

import Foundation

public enum NetworkAction : Encodable {
case received(size: String)
case sent(size: String)
}

public class NetworkSnapshot : Encodable {
let date : Date
let type : NetworkAction
let description : String

init(type: NetworkAction, description: String, date: Date = Date()) {
self.date = date
self.type = type
self.description = description
}

static func calcSize(message: String) -> String {
let rawData = message.data(using: .utf8)?.count
let bcf = ByteCountFormatter()
bcf.allowedUnits = [.useBytes]
bcf.countStyle = .file
let formatted = bcf.string(fromByteCount: Int64(rawData!))
return formatted
}
}

public class BatterySnapshot : Encodable {
let batteryLevel : Int
let date : Date

init(batteryLevel: Int, date: Date = Date()) {
self.batteryLevel = batteryLevel
self.date = date
}
}

public class ActionSnaptshot : Encodable {
let action : String
let date : Date

public init(action: String, date: Date = Date()) {
self.action = action
self.date = date
}
}

public enum BatteryState : Encodable {
case unplugged
case charging
case full
case unknown
}


public class BenchmarkSnaptshot : Encodable {
private var batteryHistory : [BatterySnapshot] = []

private var networkHistory : [NetworkSnapshot] = []


private var actionHistory : [ActionSnaptshot] = []

private var deviceID: String = ""

init(batteryHistory : [BatterySnapshot], networkHistory : [NetworkSnapshot], actionHistory : [ActionSnaptshot], deviceID : String) {
self.batteryHistory = batteryHistory
self.networkHistory = networkHistory
self.actionHistory = actionHistory
self.deviceID = deviceID
}

}
Loading