@@ -4,6 +4,7 @@ import android.content.Context
4
4
import androidx.test.ext.junit.runners.AndroidJUnit4
5
5
import androidx.test.platform.app.InstrumentationRegistry
6
6
import com.looker.core.domain.model.Repo
7
+ import com.looker.sync.fdroid.common.IndexJarValidator
7
8
import com.looker.sync.fdroid.common.Izzy
8
9
import com.looker.sync.fdroid.common.JsonParser
9
10
import com.looker.sync.fdroid.common.downloadIndex
@@ -39,15 +40,11 @@ class V1SyncableTest {
39
40
private lateinit var validator: IndexValidator
40
41
private lateinit var repo: Repo
41
42
42
- /* *
43
- * In this particular test 1 package is removed and 36 packages are updated
44
- */
45
-
46
43
@Before
47
44
fun before () {
48
45
context = InstrumentationRegistry .getInstrumentation().context
49
46
dispatcher = StandardTestDispatcher ()
50
- validator = FakeIndexValidator
47
+ validator = IndexJarValidator (dispatcher)
51
48
parser = V1Parser (dispatcher, JsonParser .parser, validator)
52
49
v2Parser = V2Parser (dispatcher, JsonParser .parser)
53
50
syncable = V1Syncable (context, FakeDownloader , dispatcher)
@@ -56,35 +53,56 @@ class V1SyncableTest {
56
53
57
54
@Test
58
55
fun benchmark_sync_v1 () = runTest(dispatcher) {
59
- memory(10 ) {
56
+ val output = memory(10 ) {
60
57
measureTimeMillis { syncable.sync(repo) }
61
58
}
59
+ println (output)
62
60
}
63
61
64
-
65
62
@Test
66
63
fun benchmark_v1_parser () = runTest(dispatcher) {
67
- memory(10 ) {
64
+ val file = FakeDownloader .downloadIndex(context, repo, " izzy" , " index-v1.jar" )
65
+ val output = memory(10 ) {
68
66
measureTimeMillis {
69
67
parser.parse(
70
- file = FakeDownloader .downloadIndex(
71
- context = context,
72
- repo = repo,
73
- fileName = " izzy" ,
74
- url = " index-v1.jar"
75
- ),
68
+ file = file,
76
69
repo = repo
77
70
)
78
71
}
79
72
}
73
+ println (output)
74
+ }
75
+
76
+ @Test
77
+ fun benchmark_v1_vs_v2_parser () = runTest(dispatcher) {
78
+ val v1File = FakeDownloader .downloadIndex(context, repo, " izzy-v1" , " index-v1.jar" )
79
+ val v2File = FakeDownloader .downloadIndex(context, repo, " izzy-v2" , " index-v2.json" )
80
+ val output1 = memory(10 ) {
81
+ measureTimeMillis {
82
+ parser.parse(
83
+ file = v1File,
84
+ repo = repo
85
+ )
86
+ }
87
+ }
88
+ val output2 = memory(10 ) {
89
+ measureTimeMillis {
90
+ v2Parser.parse(
91
+ file = v2File,
92
+ repo = repo,
93
+ )
94
+ }
95
+ }
96
+ println (output1)
97
+ println (output2)
80
98
}
81
99
82
100
@Test
83
101
fun v1tov2 () = runTest(dispatcher) {
84
102
testIndexConversion(" index-v1.jar" , " index-v2-updated.json" )
85
103
}
86
104
87
- // @Test
105
+ // @Test
88
106
fun v1tov2FDroidRepo () = runTest(dispatcher) {
89
107
testIndexConversion(" fdroid-index-v1.jar" , " fdroid-index-v2.json" )
90
108
}
0 commit comments