to clear all caches
- to pause for key entry
- to reclaim waste
- for exit."""
-
- let mutable tPrev = None
- let stats() =
- // Note that timing calls are relatively expensive on the startup path so we don't
- // make this call unless showTimes has been turned on.
- let uproc = System.Diagnostics.Process.GetCurrentProcess()
- let timeNow = uproc.UserProcessorTime.TotalSeconds
- let maxGen = System.GC.MaxGeneration
- let gcNow = [| for i in 0 .. maxGen -> System.GC.CollectionCount(i) |]
- let wsNow = uproc.WorkingSet64/1000000L
-
- match tPrev with
- | Some (timePrev, gcPrev:int[], wsPrev)->
- let spanGC = [| for i in 0 .. maxGen -> System.GC.CollectionCount(i) - gcPrev.[i] |]
- printfn "%s TimeDelta: %4.2f MemDelta: %4d G0: %4d G1: %4d G2: %4d"
- (match msgOpt with Some msg -> msg | None -> "statistics:")
- (timeNow - timePrev)
- (wsNow - wsPrev)
- spanGC.[min 0 maxGen] spanGC.[min 1 maxGen] spanGC.[min 2 maxGen]
-
- | _ -> ()
- tPrev <- Some (timeNow, gcNow, wsNow)
-
- let processCmd (fileVersion: int) c =
- match c with
- | 'C' ->
- checkProject() |> Async.RunSynchronously |> ignore
- fileVersion
- | 'G' ->
- eprintfn "GC is running..."
- let sw = Stopwatch.StartNew()
- GC.Collect 2
- eprintfn "GC is done in %O" sw.Elapsed
- fileVersion
- | 'F' ->
- checkFiles fileVersion |> Async.RunSynchronously |> ignore
- (fileVersion + 1)
- | 'R' ->
- findAllReferences fileVersion |> Async.RunSynchronously |> ignore
- fileVersion
- | 'L' ->
- getDeclarations fileVersion |> Async.RunSynchronously
- fileVersion
- | 'W' ->
- wasteMemory()
- fileVersion
- | 'M' ->
- waste.Clear()
- fileVersion
- | 'S' ->
- stats()
- fileVersion
- | 'X' ->
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
- fileVersion
- | 'P' ->
- eprintfn "pausing (press any key)...";
- System.Console.ReadKey() |> ignore
- fileVersion
- | _ -> fileVersion
-
- let rec console fileVersion =
- match Console.ReadKey().Key with
- | ConsoleKey.C -> processCmd fileVersion 'C' |> console
- | ConsoleKey.G -> processCmd fileVersion 'G' |> console
- | ConsoleKey.F -> processCmd fileVersion 'F' |> console
- | ConsoleKey.R -> processCmd fileVersion 'R' |> console
- | ConsoleKey.L -> processCmd fileVersion 'L' |> console
- | ConsoleKey.W -> processCmd fileVersion 'W' |> console
- | ConsoleKey.M -> processCmd fileVersion 'M' |> console
- | ConsoleKey.X -> processCmd fileVersion 'X' |> console
- | ConsoleKey.P -> processCmd fileVersion 'P' |> console
- | ConsoleKey.Enter -> ()
- | _ -> console fileVersion
-
- let runScript (script:string) =
- (0,script) ||> Seq.fold processCmd |> ignore
-
- match scriptOpt with
- | None -> console 0
- | Some s -> runScript s
- 0
\ No newline at end of file