Skip to content

Commit

Permalink
imp(sync): add fdroid attribution in all model classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Jan 2, 2025
1 parent 24fe5ac commit 303187a
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 219 deletions.

This file was deleted.

1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@ looker-room = { id = "looker.room", version = "unspecified" }
looker-serialization = { id = "looker.serialization", version = "unspecified" }

[bundles]
test-unit = ["coroutines-test", "kotlin-test"]
test-android = ["test-runner", "test-rules", "test-ext", "test-espresso-core", "coroutines-test", "kotlin-test"]
test-ui = ["test-runner", "test-rules", "test-espresso-core", "test-uiautomator", "coroutines-test", "kotlin-test"]
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class EntrySyncableTest {

@Test
fun benchmark_sync_full() = runTest(dispatcher) {
memory(10) {
val output = memory(10) {
measureTimeMillis { syncable.sync(repo) }
}
println(output)
}

@Test
fun benchmark_entry_parser() = runTest(dispatcher) {
memory(10) {
val output = memory(10) {
measureTimeMillis {
parser.parse(
file = FakeDownloader.downloadIndex(
Expand All @@ -75,6 +76,7 @@ class EntrySyncableTest {
)
}
}
println(output)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.looker.core.domain.model.Repo
import com.looker.sync.fdroid.common.IndexJarValidator
import com.looker.sync.fdroid.common.Izzy
import com.looker.sync.fdroid.common.JsonParser
import com.looker.sync.fdroid.common.downloadIndex
Expand Down Expand Up @@ -39,15 +40,11 @@ class V1SyncableTest {
private lateinit var validator: IndexValidator
private lateinit var repo: Repo

/**
* In this particular test 1 package is removed and 36 packages are updated
*/

@Before
fun before() {
context = InstrumentationRegistry.getInstrumentation().context
dispatcher = StandardTestDispatcher()
validator = FakeIndexValidator
validator = IndexJarValidator(dispatcher)
parser = V1Parser(dispatcher, JsonParser.parser, validator)
v2Parser = V2Parser(dispatcher, JsonParser.parser)
syncable = V1Syncable(context, FakeDownloader, dispatcher)
Expand All @@ -56,35 +53,56 @@ class V1SyncableTest {

@Test
fun benchmark_sync_v1() = runTest(dispatcher) {
memory(10) {
val output = memory(10) {
measureTimeMillis { syncable.sync(repo) }
}
println(output)
}


@Test
fun benchmark_v1_parser() = runTest(dispatcher) {
memory(10) {
val file = FakeDownloader.downloadIndex(context, repo, "izzy", "index-v1.jar")
val output = memory(10) {
measureTimeMillis {
parser.parse(
file = FakeDownloader.downloadIndex(
context = context,
repo = repo,
fileName = "izzy",
url = "index-v1.jar"
),
file = file,
repo = repo
)
}
}
println(output)
}

@Test
fun benchmark_v1_vs_v2_parser() = runTest(dispatcher) {
val v1File = FakeDownloader.downloadIndex(context, repo, "izzy-v1", "index-v1.jar")
val v2File = FakeDownloader.downloadIndex(context, repo, "izzy-v2", "index-v2.json")
val output1 = memory(10) {
measureTimeMillis {
parser.parse(
file = v1File,
repo = repo
)
}
}
val output2 = memory(10) {
measureTimeMillis {
v2Parser.parse(
file = v2File,
repo = repo,
)
}
}
println(output1)
println(output2)
}

@Test
fun v1tov2() = runTest(dispatcher) {
testIndexConversion("index-v1.jar", "index-v2-updated.json")
}

// @Test
// @Test
fun v1tov2FDroidRepo() = runTest(dispatcher) {
testIndexConversion("fdroid-index-v1.jar", "fdroid-index-v2.json")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal inline fun memory(
repetition: Int,
extraMessage: String? = null,
block: () -> Long,
) {
): String {
if (extraMessage != null) {
println("=".repeat(50))
println(extraMessage)
Expand All @@ -20,11 +20,16 @@ internal inline fun memory(
times[iteration] = block().toDouble()
}
val meanAndDeviation = times.culledMeanAndDeviation()
println("=".repeat(50))
println(times.joinToString(" | "))
println("${meanAndDeviation.first} ms ± ${meanAndDeviation.second.toFloat()} ms")
println("=".repeat(50))
println()
return buildString {
append("=".repeat(50))
append("\n")
append(times.joinToString(" | "))
append("\n")
append("${meanAndDeviation.first} ms ± ${meanAndDeviation.second.toFloat()} ms")
append("\n")
append("=".repeat(50))
append("\n")
}
}

private fun DoubleArray.culledMeanAndDeviation(): Pair<Double, Double> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.looker.sync.fdroid.v1.model

/*
* AppV1 is licensed under the GPL 3.0 to FDroid Organization.
* */

import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.looker.sync.fdroid.v1.model

/*
* IndexV1 is licensed under the GPL 3.0 to FDroid Organization.
* */

import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.looker.sync.fdroid.v1.model

/*
* Localized is licensed under the GPL 3.0 to FDroid Organization.
* */

import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.looker.sync.fdroid.v1.model

/*
* PackageV1, PermissionV1 are licensed under the GPL 3.0 to FDroid Organization.
* */

import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Loading

0 comments on commit 303187a

Please sign in to comment.