mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
log type evals perf when option is on (#7729)
This commit is contained in:
parent
a8399d3933
commit
0127fd67ad
@ -583,7 +583,13 @@ interface CodeFlowAnalyzerCacheEntry {
|
||||
codeFlowAnalyzer: CodeFlowAnalyzer;
|
||||
}
|
||||
|
||||
export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions: EvaluatorOptions): TypeEvaluator {
|
||||
type LogWrapper = <T extends (...args: any[]) => any>(func: T) => (...args: Parameters<T>) => ReturnType<T>;
|
||||
|
||||
export function createTypeEvaluator(
|
||||
importLookup: ImportLookup,
|
||||
evaluatorOptions: EvaluatorOptions,
|
||||
wrapWithLogger: LogWrapper
|
||||
): TypeEvaluator {
|
||||
const symbolResolutionStack: SymbolResolutionStackEntry[] = [];
|
||||
const asymmetricAccessorAssignmentCache = new Set<number>();
|
||||
const speculativeTypeTracker = new SpeculativeTypeTracker();
|
||||
@ -21825,7 +21831,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
return UnknownType.create();
|
||||
}
|
||||
|
||||
function getFunctionInferredReturnType(type: FunctionType, args?: ValidateArgTypeParams[]) {
|
||||
function _getFunctionInferredReturnType(type: FunctionType, args?: ValidateArgTypeParams[]) {
|
||||
let returnType: Type | undefined;
|
||||
let isIncomplete = false;
|
||||
const analyzeUnannotatedFunctions = true;
|
||||
@ -26929,6 +26935,9 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
});
|
||||
}
|
||||
|
||||
// Track these apis internal usages when logging is on. otherwise, it should be noop.
|
||||
const getFunctionInferredReturnType = wrapWithLogger(_getFunctionInferredReturnType);
|
||||
|
||||
const evaluatorInterface: TypeEvaluator = {
|
||||
runWithCancellationToken,
|
||||
getType,
|
||||
|
@ -55,11 +55,14 @@ export function createTypeEvaluatorWithTracker(
|
||||
|
||||
// Wrap all functions with either a logger or a timer.
|
||||
importLookup = wrapWithLogger(importLookup);
|
||||
const evaluator = createTypeEvaluator(importLookup, evaluatorOptions);
|
||||
const evaluator = createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger);
|
||||
|
||||
// Track these apis external usages when logging is on. otherwise, it should be noop.
|
||||
const keys = Object.keys(evaluator);
|
||||
keys.forEach((k) => {
|
||||
const entry = (evaluator as any)[k];
|
||||
if (typeof entry === 'function') {
|
||||
if (typeof entry === 'function' && entry.name) {
|
||||
// Only wrap functions that aren't wrapped already.
|
||||
(evaluator as any)[k] = wrapWithLogger(entry);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user