private static void ShowTimeSourcesCommand(List <string> args, CmdIO.TTY io, UUID limitedToScene) { if (args[0] == "help") { io.Write("Show time sources"); } else { FormattedListBuilder fb = new FormattedListBuilder() .AddColumn("Source", 20) .AddColumn("Elapsed time (s)", 20) .AddColumn("Ticks per secs", 20) .AddHeader() .AddSeparator(); fb.AddData("Stopwatch", TimeProvider.StopWatch.TicksToSecs(TimeProvider.StopWatch.TickCount).ToString("N3"), TimeProvider.StopWatch.Frequency); fb.AddData("Environment", TimeProvider.Environment.TicksToSecs(TimeProvider.Environment.TickCount).ToString("N3"), TimeProvider.Environment.Frequency); io.Write(fb.ToString()); } }
private static void ShowMemoryCommand(List <string> args, CmdIO.TTY io, UUID limitedToScene) { if (args[0] == "help") { io.Write("Shows current memory usage by simulator"); } else { Process p = Process.GetCurrentProcess(); FormattedListBuilder b = new FormattedListBuilder(); const long MB_DIV = 1048576; b.AddColumn("", 20); b.AddColumn("Current (MB)", 15); b.AddColumn("Peak (MB)", 15); b.AddHeader(); b.AddSeparator(); b.AddData("GC Heap", (GC.GetTotalMemory(false) + MB_DIV - 1) / MB_DIV, ""); b.AddData("Process memory", (p.WorkingSet64 + MB_DIV - 1) / MB_DIV, (p.PeakWorkingSet64 + MB_DIV - 1) / MB_DIV); io.WriteFormatted(b.ToString()); } }
private void RemoveAllNpcsCommand(List <string> args, Main.Common.CmdIO.TTY io, UUID limitedToScene) { if (args[0] == "help" || args.Count < 3) { io.Write("remove all npcs - Remove all NPCs\n" + "remove all npcs persistentonly - Remove all persistent npcs\n" + "remove all npcs nonpersistentonly - Remove all non-persistent npcs"); return; } bool persistentonly = (args.Count > 3 && args[3] == "persistentonly"); bool nonpersistentonly = (args.Count > 3 && args[3] == "nonpersistentonly"); UUID selectedScene = io.SelectedScene; if (limitedToScene != UUID.Zero) { selectedScene = limitedToScene; } SceneInterface scene; if (!m_KnownScenes.TryGetValue(selectedScene, out scene)) { scene = null; } if (scene == null) { io.Write("No scene selected"); return; } NpcAgent npc; var npcs = new List <UUID>(); foreach (IAgent agent in scene.Agents) { if (agent.IsNpc) { npcs.Add(agent.ID); } } var formattedListBuilder = new FormattedListBuilder(); formattedListBuilder.AddColumn("NPC", 40); formattedListBuilder.AddColumn("Status", 20); formattedListBuilder.AddHeader(); formattedListBuilder.AddSeparator(); foreach (UUID id in npcs) { if (!m_NpcAgents.TryGetValue(id, out npc)) { formattedListBuilder.AddData(id, "Not found"); } else if (scene != null && npc.CurrentScene != scene) { formattedListBuilder.AddData(id, "Not in region"); } else if (!m_NpcAgents.Remove(id, out npc)) { formattedListBuilder.AddData(id, "Skipped"); } else if ((persistentonly && npc.NpcPresenceService != m_NpcPresenceService) || (nonpersistentonly && npc.NpcPresenceService == m_NpcPresenceService)) { /* skip non-persistent */ } else { try { npc.CurrentScene.Remove(npc); RemoveNpcData(npc); formattedListBuilder.AddData(id, "Removed"); } catch { formattedListBuilder.AddData(id, "Failed to remove"); } } } io.Write(formattedListBuilder.ToString()); }