public void ProfilingDataRegisterUnRegisterNodesTest() { //Arrange var nodesList = new List <NodeModel>(); var profiling = new ProfilingData(); var cbn = CreateCodeBlockNode(); //Act profiling.RegisterNode(cbn); var nodeData = profiling.NodeProfilingData; //Assert //Checking that the code block was registered correctly Assert.IsNotNull(nodeData); Assert.AreEqual(nodeData.Count, 1); //Act profiling.UnregisterNode(nodeData.First().Key); //Assert //Checking that the code block was unregistered successfully Assert.AreEqual(nodeData.Count, 0); var cbn2 = CreateCodeBlockNode(); nodesList.Add(cbn2); //Act profiling.UnregisterDeletedNodes(nodesList); nodeData = profiling.NodeProfilingData; //Assert //Checking that the second code block was unregistered correctly Assert.AreEqual(nodeData.Count, 0); }
//--------------------------------------------------------------- #endregion //--------------------------------------------------------------- //--------------------------------------------------------------- #region Initialisation //--------------------------------------------------------------- /// <summary> /// Creates the DebugHelp page. /// </summary> internal DebugProfiling() : base(Math.Vector2.One) { #if PROFILE profiler = new GuiText(1024, 768, new System.Drawing.Font("Lucida Console", 11), Color.White); Children.Add(profiler); data = new ProfilingData(); #else profiler = new GuiText(1024, 768, new System.Drawing.Font("Arial", 14), Color.White); profiler.Text = "Profiling not enabled!"; profiler.Update(Color.From(0x80, 0, 0, 0)); Children.Add(profiler); #endif }
/// <summary> /// Creates a new profiling function. /// </summary> /// <param name="name">A string that contains a unique name.</param> /// <param name="start">If true create and starts the profiling if possible, otherwise create only.</param> /// <returns>Returns a <see cref="ProfilingData"/> Class for handle a profiling directly, /// returns null if <paramref name="name"/> already exist.</returns> public ProfilingData Create(string name, bool start) { if (_profiles.ContainsKey(name)) { return(null); } ProfilingData pd = new ProfilingData(); _profiles.Add(name, pd); if (start) { pd.Start(); } return(pd); }
public void NodeProfilingDataDispose() { //Arrange var profiling = new ProfilingData(); var cbn = CreateCodeBlockNode(); profiling.RegisterNode(cbn); var nodeData = profiling.NodeProfilingData; //Act var timeSpan = nodeData.First().Value.ExecutionTime; nodeData.First().Value.Dispose(); //Assert Assert.IsNull(timeSpan); Assert.IsNotNull(nodeData); Assert.AreEqual(nodeData.Count, 1); }
internal override ICacheClient TryExecute(ICacheClient client) { if (!CanExecute) { return(null); } Dbg.CheckThat(Params.Count <= 1); try { Profiler.IsActive = true; Profiler.Start("DESC"); var serverInfo = client.GetClusterInformation(); ProfilingData profilerResult = Profiler.End(); if (Params.Count == 1) { string tableName = Params[0]; foreach (var typeDescription in serverInfo.Schema) { if (tableName.ToUpper() == typeDescription.TypeName.ToUpper()) { LogTypeInfo(typeDescription); break; } } } else { foreach (var info in serverInfo.ServersStatus) { Logger.Write(""); Logger.Write("Server process"); Logger.Write("----------------------------------------------------------------------------"); //Logger.Write(" server name = {0}", serverInfo.ServerProcessInfo.Host); Logger.Write(" image type = {0} bits", info.Bits); Logger.Write(" started at = {0}", info.StartTime); Logger.Write(" active clients = {0}", info.ConnectedClients); Logger.Write(" threads = {0}", info.Threads); Logger.Write(" physical memory = {0} MB", info.WorkingSet / 1000000); Logger.Write(" virtual memory = {0} MB", info.VirtualMemory / 1000000); Logger.Write("software version = {0} ", info.SoftwareVersion); Logger.Write(""); } Logger.Write("Tables"); Logger.Write("-----------------------------------------------------------------------------"); string header = $"| {"Name",15} | {"Zip",5} |"; Logger.Write(header); Logger.Write("-----------------------------------------------------------------------------"); foreach (var typeDescription in serverInfo.Schema) { string compression = typeDescription.UseCompression.ToString(); Logger.Write("| {0,15} | {1,5} |", typeDescription.TypeName, compression ); } Logger.Write("-----------------------------------------------------------------------------"); } Logger.Write("The call took {0} milliseconds", profilerResult.TotalTimeMiliseconds); } catch (Exception ex) { Profiler.End(); Logger.WriteEror("Can not execute DESC : {0}", ex.Message); return(null); } return(client); }
/// <summary> /// /// </summary> /// <returns></returns> internal override ICacheClient TryExecute(ICacheClient client) { if (!CanExecute) { return(client); } Dbg.CheckThat(Params.Count >= 2); IList <CachedObject> listResult = null; try { Dbg.CheckThat(Query != null); Profiler.IsActive = true; Profiler.Start("SELECT"); listResult = client.GetObjectDescriptions(Query); bool dumpOk = true; // the third parameter(optional) is the output file name if (Params.Count == 3) { dumpOk = Logger.DumpFile(Params[2]); } if (dumpOk) { Logger.Write("["); for (int i = 0; i < listResult.Count; i++) { Logger.Write(listResult[i].AsJson()); if (i < listResult.Count - 1) { Logger.Write(","); } } Logger.Write("]"); if (Params.Count == 3) { Logger.EndDump(); } } } catch (CacheException ex) { Logger.WriteEror("Can not execute GET : {0} {1}", ex.Message, ex.ServerMessage); return(client); } catch (Exception ex) { Logger.WriteEror("Can not execute GET : {0}", ex.Message); return(client); } finally { ProfilingData profilerResult = Profiler.End(); int count = 0; if (listResult != null) { count = listResult.Count; } Logger.Write("Found {0} items. The call took {1} miliseconds", count, profilerResult.TotalTimeMiliseconds); } return(client); }