private void AddProfilerIfNotNull(string profilerName, ThreadProfiler threadProfiler)
 {
     if (threadProfiler != null)
     {
         ProfilerItems.Add(new ThreadProfilerWithName(profilerName, threadProfiler));
     }
 }
Пример #2
0
 public void Dump()
 {
     try
     {
         StringBuilder dump;
         string        path = null;
         for (; m_currentDumpNumber < 100; m_currentDumpNumber++)
         {
             path = string.Concat(VRage.FileSystem.MyFileSystem.UserDataPath, string.Format("\\dump{0}.xml", m_currentDumpNumber));
             if (!VRage.FileSystem.MyFileSystem.FileExists(path))
             {
                 break;
             }
         }
         if (path == null)
         {
             return;
         }
         var stream = VRage.FileSystem.MyFileSystem.OpenWrite(path);
         if (stream == null)
         {
             return;
         }
         var wr = new System.IO.StreamWriter(stream);
         dump = ThreadProfiler.Dump();
         wr.Write(dump);
         wr.Close();
         stream.Close();
     }
     catch { }
 }
Пример #3
0
        private HeartbeatManager()
        {
            var thread = ThreadProfiler.Create(ThreadStart);

            thread.IsBackground = true;
            thread.Name         = nameof(HeartbeatManager) + "." + nameof(Thread);
            thread.Start();
        }
Пример #4
0
        public void ProfileCustomValue(string name, float value, MyTimeSpan?customTime = null, string timeFormat = null, string valueFormat = null, [CallerMemberName] string member = "", [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
        {
            if (m_levelLimit != -1)
            {
                return;
            }

            ThreadProfiler.ProfileCustomValue(name, member, line, file, value, customTime, timeFormat, valueFormat);
        }
Пример #5
0
 private AwakeSleepSimulation(RealTimeConfig config)
 {
     threadProfiler = new ThreadProfiler();
     this.config    = config;
 }
		protected virtual void Awake() {
			var stockPathFindType = typeof(PathFind);
			const BindingFlags fieldFlags = BindingFlags.NonPublic | BindingFlags.Instance;

			_fieldpathUnits = stockPathFindType.GetField("m_pathUnits", fieldFlags);
			_fieldQueueFirst = stockPathFindType.GetField("m_queueFirst", fieldFlags);
			_fieldQueueLast = stockPathFindType.GetField("m_queueLast", fieldFlags);
			_fieldQueueLock = stockPathFindType.GetField("m_queueLock", fieldFlags);
			_fieldTerminated = stockPathFindType.GetField("m_terminated", fieldFlags);
			_fieldCalculating = stockPathFindType.GetField("m_calculating", fieldFlags);
			_fieldPathFindThread = stockPathFindType.GetField("m_pathFindThread", fieldFlags);

			_buffer = new BufferItem[65536];
			_bufferLock = PathManager.instance.m_bufferLock;
			PathUnits = PathManager.instance.m_pathUnits;
			QueueLock = new object();
			_laneLocation = new uint[262144];
			_laneTarget = new PathUnit.Position[262144];
			_bufferMin = new int[1024];
			_bufferMax = new int[1024];

			if (pathUnitExtVehicleType == null)
				pathUnitExtVehicleType = new ExtVehicleType?[PathUnits.m_size];

			m_pathfindProfiler = new ThreadProfiler();
			CustomPathFindThread = new Thread(PathFindThread) { Name = "Pathfind" };
			CustomPathFindThread.Priority = SimulationManager.SIMULATION_PRIORITY;
			CustomPathFindThread.Start();
			if (!CustomPathFindThread.IsAlive) {
				//CODebugBase<LogChannel>.Error(LogChannel.Core, "Path find thread failed to start!");
				Log.Error("Path find thread failed to start!");
			}

		}
 public ThreadProfilerWithName(string name, ThreadProfiler threadProfiler)
 {
     this.name           = name ?? throw new ArgumentNullException(nameof(name));
     this.threadProfiler = threadProfiler ?? throw new ArgumentNullException(nameof(threadProfiler));
 }
        protected virtual void Awake()
        {
            var stockPathFindType = typeof(PathFind);
            const BindingFlags fieldFlags = BindingFlags.NonPublic | BindingFlags.Instance;

            _fieldpathUnits = stockPathFindType.GetField("_pathUnits", fieldFlags);
            _fieldQueueFirst = stockPathFindType.GetField("QueueFirst", fieldFlags);
            _fieldQueueLast = stockPathFindType.GetField("QueueLast", fieldFlags);
            _fieldQueueLock = stockPathFindType.GetField("QueueLock", fieldFlags);
            _fieldTerminated = stockPathFindType.GetField("Terminated", fieldFlags);
            _fieldCalculating = stockPathFindType.GetField("Calculating", fieldFlags);
            _fieldPathFindThread = stockPathFindType.GetField("PathFindThread", fieldFlags);

            _buffer = new BufferItem[65536];
            _bufferLock = PathManager.instance.m_bufferLock;
            PathUnits = PathManager.instance.m_pathUnits;
            QueueLock = new object();
            _laneLocation = new uint[262144];
            _laneTarget = new PathUnit.Position[262144];
            _bufferMin = new int[1024];
            _bufferMax = new int[1024];

            m_pathfindProfiler = new ThreadProfiler();

            CustomPathFindThread = new Thread(PathFindThread) {Name = "Pathfind"};
            CustomPathFindThread.Start();
            if (!CustomPathFindThread.IsAlive)
            {
                //CODebugBase<LogChannel>.Error(LogChannel.Core, "Path find thread failed to start!");
                Debug.LogError("Path find thread failed to start!", this);
            }
        }
Пример #9
0
 public void InitMemoryHack(string name)
 {
     ThreadProfiler.InitMemoryHack(name);
 }
Пример #10
0
 public void EndProfilingBlock(float customValue = 0, MyTimeSpan?customTime = null, string timeFormat = null, string valueFormat = null, [CallerMemberName] string member = "", [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
 {
     ThreadProfiler.EndBlock(member, line, file, customTime, customValue, timeFormat, valueFormat);
 }
Пример #11
0
 public void StartProfilingBlock(string blockName = null, float customValue = 0, [CallerMemberName] string member = "", [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
 {
     ThreadProfiler.StartBlock(blockName, member, line, file);
 }