зеркало из https://github.com/github/codeql.git
QL: Add a query for finding the predicates with the highest tuple sums.
This commit is contained in:
Родитель
7595c1c306
Коммит
23b9abcbbf
|
@ -362,31 +362,6 @@ module KindPredicatesLog {
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the predicate represented by `inLayer` was run in the `iteration`'iteration
|
||||
* of the SCC computation rooted at `recursive`.
|
||||
*/
|
||||
private predicate ran(ComputeRecursive recursive, int iteration, InLayer inLayer) {
|
||||
exists(int index |
|
||||
inLayer = layerEventRank(recursive, index) and
|
||||
inLayer.getPredicateIterationMillis().getNumber(iteration) >= 0
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next iteration in which the predicate `pred` in the `iteration`'th iteration
|
||||
* of a recursive SCC rooted at `recursive` should be evaluated.
|
||||
*/
|
||||
int nextPipeline(ComputeRecursive recursive, int iteration, InLayer inLayer) {
|
||||
iteration = 0 and
|
||||
if ran(recursive, iteration, inLayer) then result = 1 else result = 0
|
||||
or
|
||||
iteration > 1 and
|
||||
exists(int n | n = nextPipeline(recursive, iteration - 1, inLayer) |
|
||||
if ran(recursive, iteration, inLayer) then result = n + 1 else result = n
|
||||
)
|
||||
}
|
||||
|
||||
bindingset[this]
|
||||
signature class ResultSig;
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Shows a list of the "slow" predicates by tuple sum.
|
||||
*/
|
||||
|
||||
import ql
|
||||
import codeql_ql.StructuredLogs
|
||||
import KindPredicatesLog
|
||||
|
||||
module SumCounts implements Fold<int> {
|
||||
int base(PipeLineRun run) { result = sum(int i | | run.getCount(i)) }
|
||||
|
||||
bindingset[s]
|
||||
int fold(PipeLineRun run, int s) { result = sum(int i | | run.getCount(i)) + s }
|
||||
}
|
||||
|
||||
int sumTuples(SummaryEvent event) {
|
||||
result = strictsum(int i | | event.(ComputeSimple).getPipelineRun().getCount(i))
|
||||
or
|
||||
result = Iterate<int, SumCounts>::iterate(event)
|
||||
}
|
||||
|
||||
int predicateRank(SummaryEvent evt) {
|
||||
evt = rank[result](SummaryEvent y, int s | s = sumTuples(y) | y order by s desc)
|
||||
}
|
||||
|
||||
from SummaryEvent evt, int s
|
||||
where predicateRank(evt) < 50 and s = sumTuples(evt)
|
||||
select evt, s order by s desc
|
Загрузка…
Ссылка в новой задаче