Skip to content

Commit a343a59

Browse files
committed
Changes
1 parent 1af40cc commit a343a59

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

tests/FSharp.Compiler.Service.Tests2/DepResolving.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ module internal AutomatedDependencyResolving =
339339
DepsResult.Files = nodes
340340
DepsResult.Graph = graph
341341
}
342-
log "Done"
343342
res
344343

345344
/// <summary>
@@ -383,4 +382,4 @@ let analyseEfficiency (result : DepsResult) : unit =
383382
|> Array.map (fun f -> depthDfs f.Idx)
384383
|> Array.max
385384

386-
printfn $"Total file size: {totalFileSize}. Max depth: {maxDepth}. Max Depth/Size = %.2f{double(maxDepth) / double(totalFileSize)}"
385+
log $"Total file size: {totalFileSize}. Max depth: {maxDepth}. Max Depth/Size = %.1f{100.0 * double(maxDepth) / double(totalFileSize)}%%"

tests/FSharp.Compiler.Service.Tests2/Program.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ let main _ =
1111
TestDepResolving.TestProject(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")
1212
//runCompiler ()
1313
//TestDepResolving.TestHardcodedFiles()
14+
printfn ""
1415
TestDepResolving.TestProject(@"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj")
1516
//RunCompiler.runGrapher()
1617
0

tests/FSharp.Compiler.Service.Tests2/TestDepResolving.fs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,19 @@ let TestHardcodedFiles() =
107107
analyseEfficiency graph
108108

109109
let private parseProjectAndGetSourceFiles (projectFile : string) =
110-
log "building project"
111110
let m = AnalyzerManager()
112111
let analyzer = m.GetProject(projectFile)
113112
let results = analyzer.Build()
114113
// TODO Generalise for multiple TFMs
115114
let res = results.Results |> Seq.head
116115
let files = res.SourceFiles
117-
log "built"
116+
log "built project using Buildalyzer"
118117
files
119118

120119
[<TestCase(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")>]
121120
[<TestCase(@"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj")>]
122121
let TestProject (projectFile : string) =
123-
log "start"
122+
log $"Start finding file dependency graph for {projectFile}"
124123
let files = parseProjectAndGetSourceFiles projectFile
125124
let files =
126125
files
@@ -130,22 +129,24 @@ let TestProject (projectFile : string) =
130129
{Name = f; Code = code; AST = ast}
131130
)
132131
|> Array.filter (fun x ->
133-
ASTVisit.extractModuleRefs x.AST
134-
|> Array.forall (function | ReferenceOrAbbreviation.Reference _ -> true | ReferenceOrAbbreviation.Abbreviation _ -> false)
132+
true
133+
//ASTVisit.extractModuleRefs x.AST
134+
//|> Array.forall (function | ReferenceOrAbbreviation.Reference _ -> true | ReferenceOrAbbreviation.Abbreviation _ -> false)
135135
)
136136
let N = files.Length
137137
log $"{N} files read and parsed"
138138

139139
let graph = AutomatedDependencyResolving.detectFileDependencies files
140-
log "deps detected"
140+
log "Deps detected"
141141

142142
let totalDeps = graph.Graph |> Seq.sumBy (fun (KeyValue(idx, deps)) -> deps.Length)
143143
let maxPossibleDeps = (N * (N-1)) / 2
144144

145145
let graphJson = graph.Graph |> Seq.map (fun (KeyValue(idx, deps)) -> graph.Files[idx].Name, deps |> Array.map (fun d -> graph.Files[d].Name)) |> dict
146146
let json = JsonConvert.SerializeObject(graphJson, Formatting.Indented)
147-
System.IO.File.WriteAllText("deps_graph.json", json)
147+
let path = $"{System.IO.Path.GetFileName(projectFile)}.deps.json"
148+
System.IO.File.WriteAllText(path, json)
148149

149-
printfn $"Analysed {N} files, detected {totalDeps}/{maxPossibleDeps} file dependencies."
150-
printfn "Wrote graph as json in deps_graph.json"
150+
log $"Analysed {N} files, detected {totalDeps}/{maxPossibleDeps} file dependencies (%.1f{100.0 * double(totalDeps) / double(maxPossibleDeps)}%%)."
151+
log $"Wrote graph in {path}"
151152
analyseEfficiency graph

0 commit comments

Comments
 (0)