Source file src/internal/analysis/gotestchecker/profile.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package gotestchecker 6 7 // This file defines the hooks by which the analysis of one package 8 // records its costs. In this version they do nothing. 9 // 10 // TODO(adonovan): implement profiling (go test -debug-vetprofile), 11 // in pending CL 856982. 12 13 import ( 14 "go/analysis" 15 "internal/analysis/gotestchecker/protocol" 16 ) 17 18 // Phases of the analysis of one package. 19 const ( 20 phaseParse = "parse" // parsing Go files 21 phaseTypecheck = "typecheck" // type checking (including reading export data of imports) 22 phaseExport = "export" // writing export data 23 phaseFacts = "facts" // decoding and encoding an analyzer's facts 24 phaseRun = "run" // an analyzer's Run function 25 phaseWrite = "write" // writing pass files 26 ) 27 28 // A profiler records the costs of one tool process. 29 // A nil *profiler is valid and does nothing. 30 type profiler struct{} 31 32 // startProfiler starts profiling if the request asks for it, 33 // and returns nil otherwise. 34 func startProfiler(areq *protocol.AnalyzeRequest) (*profiler, error) { return nil, nil } 35 36 // setAnalyzers records the analyzers of the tool, in index order. 37 func (p *profiler) setAnalyzers(analyzers []*analysis.Analyzer) {} 38 39 // do calls f, attributing its costs to the specified phase and 40 // analyzer (if not -1). 41 func (p *profiler) do(phase string, analyzer int, f func()) { f() } 42 43 // doErr is like do, but returns the error result of f. 44 func (p *profiler) doErr(phase string, analyzer int, f func() error) error { return f() } 45 46 // factsOut records the facts encoded by an analyzer. 47 func (p *profiler) factsOut(analyzer int, own, deps, bytes int) {} 48 49 // factsIn records the size of the facts of a direct import decoded 50 // for an analyzer. 51 func (p *profiler) factsIn(analyzer int, bytes int) {} 52 53 // factPassFile records the reading of a pass file of a direct import 54 // for an analyzer, and whether it was empty (no facts or failure). 55 func (p *profiler) factPassFile(analyzer int, empty bool) {} 56 57 // factsDecoded records the number of facts decoded for an analyzer, 58 // and the number of those discarded. 59 func (p *profiler) factsDecoded(analyzer int, decoded, discarded int) {} 60 61 // finish stops profiling, writes the profile, and writes the stats 62 // file, attributing CPU time to labels. 63 func (p *profiler) finish() error { return nil } 64