22
33import org .variantsync .diffdetective .util .CSV ;
44import org .variantsync .diffdetective .variation .diff .DiffTree ;
5- import org .variantsync .diffdetective .variation .tree .view .query .Query ;
6- import org .variantsync .diffdetective .variation .tree .view .query .VariantQuery ;
5+ import org .variantsync .diffdetective .variation .diff .view .DiffView ;
6+ import org .variantsync .diffdetective .variation .tree .view .relevance .Relevance ;
7+ import org .variantsync .diffdetective .variation .tree .view .relevance .Configure ;
78
89import static org .variantsync .functjonal .Functjonal .intercalate ;
910
11+ /**
12+ * Single data point in our feasibility study.
13+ * An object of this class corresponds to a row in the CSV files we export.
14+ * This row contains all information for benchmarking a single view generation:
15+ * @param commit The commit on which views were generated.
16+ * @param file The file of the patch that was analysed.
17+ * @param relevance The relevance predicate from which the views were generated.
18+ * @param msNaive Milliseconds it took to generate the view with the {@link DiffView#naive(DiffTree, Relevance) naive algorithm}
19+ * @param msOptimized Milliseconds it took to generate the view with the {@link DiffView#optimized(DiffTree, Relevance) optimized algorithm}
20+ * @param diffStatistics Various statistics on the variation diff of the analysed patch.
21+ * @param viewStatistics The same statistics as for the original variation diff but for the produced view.
22+ */
1023public record ViewEvaluation (
1124// Repository repo,
1225 String commit ,
1326 String file ,
14- Query query ,
27+ Relevance relevance ,
1528 long msNaive ,
1629 long msOptimized ,
1730 DiffStatistics diffStatistics ,
1831 DiffStatistics viewStatistics
1932) implements CSV {
33+ /**
34+ * Holds various information of a variation diff.
35+ * @param nodeCount The number of nodes contained in the variation diff.
36+ * @param annotationNodeCount The number of annotation nodes in the variation diff.
37+ */
2038 public record DiffStatistics (int nodeCount , int annotationNodeCount ) {
39+ /**
40+ * Gathers statistics of a given variation diff.
41+ * This method is side-effect free and will not alter the given diff.
42+ * @param d A variation diff to extract statistics from.
43+ * @return The extracted statistics.
44+ */
2145 public static DiffStatistics of (final DiffTree d ) {
2246 final int [] nodeCount = {0 };
2347 final int [] annotationNodeCount = {0 };
@@ -33,6 +57,13 @@ public static DiffStatistics of(final DiffTree d) {
3357 }
3458 }
3559
60+ /**
61+ * Creates the header for a CSV file in which objects of this class
62+ * can be rows.
63+ * @param delimiter The delimiter to use between rows in the CSV file (see {@link CSV#DEFAULT_CSV_DELIMITER}.
64+ * @return A string that should be the first row in a CSV file with objects of this class
65+ * as rows.
66+ */
3667 public static String makeHeader (String delimiter ) {
3768 return intercalate (delimiter ,
3869// "repository",
@@ -55,7 +86,7 @@ public String toCSV(String delimiter) {
5586// repo.getRepositoryName(),
5687 commit ,
5788 file ,
58- query .getFunctionName (),
89+ relevance .getFunctionName (),
5990// getQueryArguments(),
6091 msNaive ,
6192 msOptimized ,
@@ -65,11 +96,4 @@ public String toCSV(String delimiter) {
6596 viewStatistics .annotationNodeCount
6697 );
6798 }
68-
69- private String getQueryArguments () {
70- if (query instanceof VariantQuery ) {
71- return query .parametersToString ();
72- }
73- return "" ;
74- }
7599}
0 commit comments