diff --git a/python/tools/recorded-call-graph-metrics/ql/Metrics.ql b/python/tools/recorded-call-graph-metrics/ql/Metrics.ql new file mode 100644 index 00000000000..baa49be5ed5 --- /dev/null +++ b/python/tools/recorded-call-graph-metrics/ql/Metrics.ql @@ -0,0 +1,22 @@ +import RecordedCalls + +from string text, float number, float ratio +where + exists(int all_rcs | all_rcs = count(XMLRecordedCall rc) and ratio = number / all_rcs | + text = "Number of XMLRecordedCall" and number = all_rcs + or + text = "Number of IdentifiedRecordedCall" and number = count(IdentifiedRecordedCall rc) + or + text = "Number of UnidentifiedRecordedCall" and number = count(UnidentifiedRecordedCall rc) + ) + or + exists(int all_identified_rcs | + all_identified_rcs = count(IdentifiedRecordedCall rc) and ratio = number / all_identified_rcs + | + text = "Number of points-to ResolvableRecordedCall" and + number = count(PointsToBasedCallGraph::ResolvableRecordedCall rc) + or + text = "Number of points-to NOT ResolvableRecordedCall" and + number = all_identified_rcs - count(PointsToBasedCallGraph::ResolvableRecordedCall rc) + ) +select text, number, ratio * 100 + "%" as percent diff --git a/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll b/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll index f12b4408193..664112c9b9b 100644 --- a/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll +++ b/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll @@ -77,6 +77,14 @@ class XMLCall extends XMLElement { bytecode.(XMLBytecodeAttribute).get_object_data()) or matchBytecodeExpr(expr.(Call).getFunc(), bytecode.(XMLBytecodeCall).get_function_data()) + // I experimented with allowing partial matches with + // ``` + // or + // bytecode instanceof XMLBytecodeUnknown + // ``` + // but that only gave 1% improvement for Identified calls with approx 4200 calls + // in total (only supporting BytecodeVariableName/BytecodeAttribute/BytecodeCall). + // Since it's a potential performance problem, I did not enable. ) } }