Skip to content

Commit ec47589

Browse files
committed
stats
1 parent a13f336 commit ec47589

File tree

3 files changed

+81
-23
lines changed

3 files changed

+81
-23
lines changed

src/test/scala/ch/epfl/scala/decoder/BinaryDecoderStats.scala

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ class BinaryDecoderStats extends BinaryDecoderSuite:
1313
val decoder = initDecoder("org.scala-lang", "scala3-compiler_3", "3.3.1")
1414
decoder.assertDecodeAll(
1515
expectedClasses = ExpectedCount(4426),
16-
expectedMethods = ExpectedCount(68421, ambiguous = 25, notFound = 33)
16+
expectedMethods = ExpectedCount(68421, ambiguous = 25, notFound = 33),
17+
expectedFields = ExpectedCount(12548, ambiguous = 27, notFound = 1)
1718
)
1819

1920
test("scala3-compiler:3.0.2"):
2021
val decoder = initDecoder("org.scala-lang", "scala3-compiler_3", "3.0.2")
2122
decoder.assertDecodeAll(
2223
expectedClasses = ExpectedCount(3859, notFound = 3),
23-
expectedMethods = ExpectedCount(60762, ambiguous = 24, notFound = 163)
24+
expectedMethods = ExpectedCount(60762, ambiguous = 24, notFound = 163),
25+
expectedFields = ExpectedCount(10670, ambiguous = 23, notFound = 6)
2426
)
2527

2628
test("io.github.vigoo:zio-aws-ec2_3:4.0.5 - slow".ignore):
@@ -32,15 +34,23 @@ class BinaryDecoderStats extends BinaryDecoderSuite:
3234

3335
test("org.tpolecat:doobie-h2_3:0.13.4"):
3436
val decoder = initDecoder("org.tpolecat", "doobie-h2_3", "0.13.4")
35-
decoder.assertDecodeAll(ExpectedCount(10), ExpectedCount(218))
37+
decoder.assertDecodeAll(
38+
expectedClasses = ExpectedCount(10),
39+
expectedMethods = ExpectedCount(218),
40+
expectedFields = ExpectedCount(45)
41+
)
3642

3743
test("net.zygfryd:jackshaft_3:0.2.2".ignore):
3844
val decoder = initDecoder("net.zygfryd", "jackshaft_3", "0.2.2", FetchOptions(keepProvided = true))
3945
decoder.assertDecodeAll(ExpectedCount(49, notFound = 1), ExpectedCount(454, notFound = 1))
4046

4147
test("company.jap:fields-core_3:0.4.16"):
4248
val decoder = initDecoder("company.jap", "fields-core_3", "0.4.16", FetchOptions(keepOptional = true))
43-
decoder.assertDecodeAll(ExpectedCount(245), ExpectedCount(2755, notFound = 92))
49+
decoder.assertDecodeAll(
50+
expectedClasses = ExpectedCount(245),
51+
expectedMethods = ExpectedCount(2755, notFound = 92),
52+
expectedFields = ExpectedCount(298)
53+
)
4454

4555
test("org.clulab:processors-main_3:8.5.3"):
4656
assume(!isCI)
@@ -53,7 +63,11 @@ class BinaryDecoderStats extends BinaryDecoderSuite:
5363

5464
test("com.github.simy4.xpath:xpath-to-xml-scala_3:2.3.7"):
5565
val decoder = initDecoder("com.github.simy4.xpath", "xpath-to-xml-scala_3", "2.3.7")
56-
decoder.assertDecodeAll(ExpectedCount(27), ExpectedCount(174, notFound = 2))
66+
decoder.assertDecodeAll(
67+
ExpectedCount(27),
68+
ExpectedCount(174, notFound = 2),
69+
expectedFields = ExpectedCount(20, ambiguous = 4)
70+
)
5771

5872
test("com.zengularity:benji-google_3:2.2.1".ignore):
5973
val fetchOptions = FetchOptions(
@@ -81,35 +95,49 @@ class BinaryDecoderStats extends BinaryDecoderSuite:
8195
val decoder = initDecoder("dev.zio", "zio-interop-cats_3", "23.1.0.0")(using ThrowOrWarn.ignore)
8296
decoder.assertDecodeAll(
8397
ExpectedCount(149, notFound = 9),
84-
ExpectedCount(3546, notFound = 59)
98+
ExpectedCount(3546, notFound = 59),
99+
expectedFields = ExpectedCount(144, notFound = 2)
85100
)
86101

87102
test("com.evolution:scache_3:5.1.2"):
88103
val fetchOptions = FetchOptions(
89104
repositories = Seq(MavenRepository("https://evolution.jfrog.io/artifactory/public"))
90105
)
91106
val decoder = initDecoder("com.evolution", "scache_3", "5.1.2", fetchOptions)
92-
decoder.assertDecodeAll(ExpectedCount(105), ExpectedCount(1509))
107+
decoder.assertDecodeAll(
108+
ExpectedCount(105),
109+
ExpectedCount(1509),
110+
expectedFields = ExpectedCount(161)
111+
)
93112

94113
test("com.github.j5ik2o:docker-controller-scala-dynamodb-local_:1.15.34"):
95114
val fetchOptions = FetchOptions(
96115
repositories = Seq(MavenRepository("https://maven.seasar.org/maven2/"))
97116
)
98117
val decoder = initDecoder("com.github.j5ik2o", "docker-controller-scala-dynamodb-local_3", "1.15.34", fetchOptions)
99-
decoder.assertDecodeAll(ExpectedCount(2), ExpectedCount(37))
118+
decoder.assertDecodeAll(
119+
ExpectedCount(2),
120+
ExpectedCount(37),
121+
expectedFields = ExpectedCount(5)
122+
)
100123

101124
test("eu.ostrzyciel.jelly:jelly-grpc_3:0.5.3"):
102125
val fetchOptions = FetchOptions(exclusions = Seq("io.grpc" -> "grpc-core"))
103126
val decoder = initDecoder("eu.ostrzyciel.jelly", "jelly-grpc_3", "0.5.3", fetchOptions)
104-
decoder.assertDecodeAll(ExpectedCount(24), ExpectedCount(353))
127+
decoder.assertDecodeAll(
128+
ExpectedCount(24),
129+
ExpectedCount(353),
130+
expectedFields = ExpectedCount(61)
131+
)
105132

106133
test("com.devsisters:zio-agones_3:0.1.0"):
107134
assume(!isJava8)
108135
val fetchOptions = FetchOptions(exclusions = Seq("io.grpc" -> "grpc-core"))
109136
val decoder = initDecoder("com.devsisters", "zio-agones_3", "0.1.0", fetchOptions)(using ThrowOrWarn.ignore)
110137
decoder.assertDecodeAll(
111138
ExpectedCount(83, notFound = 26),
112-
ExpectedCount(2804, ambiguous = 2, notFound = 5)
139+
ExpectedCount(2804, ambiguous = 2, notFound = 5),
140+
expectedFields = ExpectedCount(258)
113141
)
114142

115143
test("org.log4s:log4s_3:1.10.0".ignore):
@@ -133,8 +161,16 @@ class BinaryDecoderStats extends BinaryDecoderSuite:
133161

134162
test("in.nvilla:regsafe_3:0.0.1: unstable TASTy version"):
135163
val decoder = initDecoder("in.nvilla", "regsafe_3", "0.0.1")(using ThrowOrWarn.ignore)
136-
decoder.assertDecodeAll(ExpectedCount(19), ExpectedCount(158))
164+
decoder.assertDecodeAll(
165+
ExpectedCount(19),
166+
ExpectedCount(158),
167+
expectedFields = ExpectedCount(32, ambiguous = 4, notFound = 2)
168+
)
137169

138170
test("io.github.valdemargr:gql-core_3:0.3.3"):
139171
val decoder = initDecoder("io.github.valdemargr", "gql-core_3", "0.3.3")
140-
decoder.assertDecodeAll(ExpectedCount(531), ExpectedCount(7267, ambiguous = 4, notFound = 1))
172+
decoder.assertDecodeAll(
173+
ExpectedCount(531),
174+
ExpectedCount(7267, ambiguous = 4, notFound = 1),
175+
expectedFields = ExpectedCount(851, notFound = 2)
176+
)

src/test/scala/ch/epfl/scala/decoder/BinaryDecoderStatsFull.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BinaryDecoderStatsFull extends BinaryDecoderSuite:
3131
val parts = line.split(',').map(_.drop(1).dropRight(1))
3232
val (org, artifact, version) = (parts(0), parts(1), parts(2))
3333
try
34-
val (classCounter, methodCounter) = tryDecodeAll(org, artifact, version)
34+
val (classCounter, methodCounter, _) = tryDecodeAll(org, artifact, version)
3535
classCounts += classCounter.count
3636
methodCounts += methodCounter.count
3737
catch case e => println(s"cannot decode $line")
@@ -45,15 +45,15 @@ class BinaryDecoderStatsFull extends BinaryDecoderSuite:
4545
.sortBy(count => -count.successPercent)
4646
.foreach(c => println(s"${c.name} ${c.successPercent}%"))
4747

48-
def tryDecodeAll(org: String, artifact: String, version: String)(using ThrowOrWarn): (Counter, Counter) =
48+
def tryDecodeAll(org: String, artifact: String, version: String)(using ThrowOrWarn): (Counter, Counter, Counter) =
4949
val repositories =
5050
if org == "org.clulab" then Seq(MavenRepository("http://artifactory.cs.arizona.edu:8081/artifactory/sbt-release"))
5151
else if org == "com.zengularity" then
5252
Seq(MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"))
5353
else if org == "com.evolution" then Seq(MavenRepository("https://evolution.jfrog.io/artifactory/public"))
5454
else if org == "com.github.j5ik2o" then Seq(MavenRepository("https://maven.seasar.org/maven2/"))
5555
else Seq.empty
56-
def tryWith(keepOptional: Boolean, keepProvided: Boolean): Option[(Counter, Counter)] =
56+
def tryWith(keepOptional: Boolean, keepProvided: Boolean): Option[(Counter, Counter, Counter)] =
5757
try
5858
val fetchOptions = FetchOptions(keepOptional, keepProvided, repositories)
5959
val decoder = initDecoder(org, artifact, version, fetchOptions)

src/test/scala/ch/epfl/scala/decoder/testutils/BinaryDecoderSuite.scala

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ trait BinaryDecoderSuite extends CommonFunSuite:
6060
val binaryField: binary.Field = loadBinaryField(className, field)
6161
intercept[AmbiguousException](decoder.decode(binaryField))
6262

63+
def assertNotFoundField(className: String, field: String)(using munit.Location): Unit =
64+
val binaryField = loadBinaryField(className, field)
65+
intercept[NotFoundException](decoder.decode(binaryField))
66+
6367
def assertNotFound(declaringType: String, javaSig: String)(using munit.Location): Unit =
6468
val method = loadBinaryMethod(declaringType, javaSig)
6569
intercept[NotFoundException](decoder.decode(method))
@@ -83,34 +87,41 @@ trait BinaryDecoderSuite extends CommonFunSuite:
8387
def assertDecodeAll(
8488
expectedClasses: ExpectedCount = ExpectedCount(0),
8589
expectedMethods: ExpectedCount = ExpectedCount(0),
90+
expectedFields: ExpectedCount = ExpectedCount(0),
8691
printProgress: Boolean = false
8792
)(using munit.Location): Unit =
88-
val (classCounter, methodCounter) = decodeAll(printProgress)
93+
val (classCounter, methodCounter, fieldCounter) = decodeAll(printProgress)
8994
if classCounter.throwables.nonEmpty then
9095
classCounter.printThrowables()
9196
classCounter.printThrowable(0)
9297
else if methodCounter.throwables.nonEmpty then
9398
methodCounter.printThrowables()
9499
methodCounter.printThrowable(0)
95-
// methodCounter.printNotFound()
100+
fieldCounter.printNotFound()
96101
classCounter.check(expectedClasses)
97102
methodCounter.check(expectedMethods)
103+
fieldCounter.check(expectedFields)
98104

99-
def decodeAll(printProgress: Boolean = false): (Counter, Counter) =
105+
def decodeAll(printProgress: Boolean = false): (Counter, Counter, Counter) =
100106
val classCounter = Counter(decoder.name + " classes")
101107
val methodCounter = Counter(decoder.name + " methods")
108+
val fieldCounter = Counter(decoder.name + " fields")
102109
for
103110
binaryClass <- decoder.allClasses
104111
_ = if printProgress then println(s"\"${binaryClass.name}\"")
105112
decodedClass <- decoder.tryDecode(binaryClass, classCounter)
106-
binaryMethod <- binaryClass.declaredMethods
113+
binaryMethodOrField <- binaryClass.declaredMethods ++ binaryClass.declaredFields
107114
do
108-
if printProgress then println(formatDebug(binaryMethod))
109-
decoder.tryDecode(decodedClass, binaryMethod, methodCounter)
115+
if printProgress then println(formatDebug(binaryMethodOrField))
116+
binaryMethodOrField match
117+
case m: binary.Method =>
118+
decoder.tryDecode(decodedClass, m, methodCounter)
119+
case f: binary.Field =>
120+
decoder.tryDecode(decodedClass, f, fieldCounter)
110121
classCounter.printReport()
111122
methodCounter.printReport()
112-
113-
(classCounter, methodCounter)
123+
fieldCounter.printReport()
124+
(classCounter, methodCounter, fieldCounter)
114125

115126
private def loadBinaryMethod(declaringType: String, method: String)(using
116127
munit.Location
@@ -157,10 +168,21 @@ trait BinaryDecoderSuite extends CommonFunSuite:
157168
case ambiguous: AmbiguousException => counter.ambiguous += ambiguous
158169
case ignored: IgnoredException => counter.ignored += ignored
159170
case e => counter.throwables += (mthd -> e)
171+
172+
private def tryDecode(cls: DecodedClass, field: binary.Field, counter: Counter): Unit =
173+
try
174+
val decoded = decoder.decode(cls, field)
175+
counter.success += (field -> decoded)
176+
catch
177+
case notFound: NotFoundException => counter.notFound += (field -> notFound)
178+
case ambiguous: AmbiguousException => counter.ambiguous += ambiguous
179+
case ignored: IgnoredException => counter.ignored += ignored
180+
case e => counter.throwables += (field -> e)
160181
end extension
161182

162183
private def formatDebug(m: binary.Symbol): String =
163184
m match
185+
case f: binary.Field => s"\"${f.declaringClass}\", \"${formatField(f)}\""
164186
case m: binary.Method => s"\"${m.declaringClass.name}\", \"${formatMethod(m)}\""
165187
case cls => s"\"${cls.name}\""
166188

0 commit comments

Comments
 (0)