protected AbstractMessage(string type, string name, IMessageManager messageManager = null) { _type = type; _name = name; _messageManager = messageManager; TimestampInMicros = MilliSecondTimer.CurrentTimeMicros(); }
public override void Complete() { if (IsCompleted()) { // complete() was called more than once IMessage evt0 = new DefaultEvent("CAT", "BadInstrument") { Status = "TransactionAlreadyCompleted" }; evt0.Complete(); AddChild(evt0); } else { _mDurationInMicro = MilliSecondTimer.CurrentTimeMicros() - TimestampInMicros; SetCompleted(true); if (_endCallBack != null) { _endCallBack(this); } } }
public static void Test() { long start = MilliSecondTimer.UnixNowMilliSeconds(); Console.WriteLine(Conf.AsString()); PerfTestUtil.WriteLine("Test starts"); IList <Thread> threads = new List <Thread>(); for (int i = 0; i < Conf.N_THREADS; i++) { Thread thread = new Thread(TransactionTreeWorker.DoWork); threads.Add(thread); } foreach (Thread thread in threads) { thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } PerfTestUtil.WriteLine("Test ends. latency: " + (MilliSecondTimer.UnixNowMilliSeconds() - start) + " ms.\n" + "Number of transactions created: " + TransactionTreeWorker.nTransactions + "\n"); }
private void CompleteTransaction(Transaction root) { root.Depth--; var depth = root.Depth; if (depth == 0) { #region 时间间隔(毫秒计算) root.TimeSpanInMilliseconds = MilliSecondTimer.TimeSpanInMilliseconds(root.Time, MilliSecondTimer.CurrentTime()); #endregion return; } // var countE = root.Evens.Count; if (countE == 0) { return; } var rootEven = root.Evens[countE - 1]; var countT = rootEven.Transactions.Count; if (countT == 0) { return; } var currentT = rootEven.Transactions[countT - 1]; CompleteTransaction(currentT); }
public static void Test() { try { const string UNIQUE_ID = "B9"; const int N_TRANSACTIONS = 10240000; PerfTestUtil.WriteLine("Full speed send test {0} START. N_TRANSACTIONS[{1}] Sender queue size[{2}]", UNIQUE_ID, N_TRANSACTIONS, 1000); // Comment out rootTransaction. Because in real prod environment, truncating transaction rarely happens. ITransaction rootTransaction = Cat.NewTransaction("Root transaction of full speed send test " + UNIQUE_ID + " N_TRANSACTIONS [" + N_TRANSACTIONS + "]", "Root transaction of full speed send test"); long start = MilliSecondTimer.UnixNowMilliSeconds(); for (int i = 0; i < N_TRANSACTIONS; i++) { // ITransaction child = Cat.NewTransaction("Child transaction of full speed send test " + UNIQUE_ID + " N_TRANSACTIONS [" + N_TRANSACTIONS + "]", ""); ITransaction child = Cat.NewTransaction("Child", ""); child.Status = CatConstants.SUCCESS; child.Complete(); } rootTransaction.Status = CatConstants.SUCCESS; rootTransaction.Complete(); PerfTestUtil.WriteLine("Full speed send test {0} END. Latency[{1} ms]. {2}", UNIQUE_ID, (MilliSecondTimer.UnixNowMilliSeconds() - start), Cat.ToText()); } catch (Exception ex) { PerfTestUtil.WriteLine("Exception occurred in full speed send test:\n " + ex); throw ex; } }
public override void Complete() { try { if (IsCompleted()) { // complete() was called more than once IMessage evt0 = new DefaultEvent("cat", "BadInstrument") { Status = "TransactionAlreadyCompleted" }; evt0.Complete(); AddChild(evt0); } else { _mDurationInMicro = MilliSecondTimer.UnixNowMicroSeconds() - TimestampInMicros; SetCompleted(true); if (_mManager != null) { _mManager.End(this); } } } catch (Exception ex) { Cat.lastException = ex; } }
/// <summary> /// 创建事务 /// </summary> /// <param name="type">事务的类型</param> /// <param name="category">事务的分类</param> /// <param name="name">事务名称</param> public Transaction(string type, string category, string name) { // TODO: Complete member initialization this.Type = type; this.Category = category; this.Name = name; this.Time = MilliSecondTimer.CurrentTime(); }
/// <summary> /// 创建事件 /// </summary> /// <param name="name">事件名称</param> /// <param name="description">事件描述</param> public Even(string name, string description) { // TODO: Complete member initialization this.Name = name; this.Description = description; this.IsException = false; this.Time = MilliSecondTimer.CurrentTime(); }
public virtual long GetUpTime() { if (0 == startTime) { return(0); } return(MilliSecondTimer.UnixNowMilliSeconds() - startTime); }
public Context() { this.IsException = false; this.BeginTime = MilliSecondTimer.CurrentTime(); this.Guid = System.Guid.NewGuid().ToString(); this.Project = ConfigInfoHelper.Instance.Info.Project; this.ProjectCode = ConfigInfoHelper.Instance.Info.ProjectCode; this.LocalHostName = NetworkInterfaceManager.LocalHostName; this.LocalHostAddress = NetworkInterfaceManager.LocalHostAddress; }
public static void DoWork() { long start = MilliSecondTimer.UnixNowMilliSeconds(); PerfTestUtil.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " starts"); CreateSubtree(0); PerfTestUtil.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " ends. thread latency: " + (MilliSecondTimer.UnixNowMilliSeconds() - start) + " ms."); }
/// <summary> /// 创建事件 /// </summary> /// <param name="e"></param> public void NewEven(Even e) { Evens.Add(e); #region 时间间隔(毫秒计算) var count = Evens.Count; if (count > 2) { var preItem = Evens[count - 2]; var curItem = Evens[count - 1]; preItem.TimeSpanInMilliseconds = MilliSecondTimer.TimeSpanInMilliseconds(preItem.Time, curItem.Time); } #endregion }
private void Log(string severity, string pattern, params object[] args) { string timestamp = new DateTime(MilliSecondTimer.CurrentTimeMicros() * 10L).ToString("yyyy-MM-dd HH:mm:ss.fff"); string message = string.Format(pattern, args); string line = "[" + timestamp + "] [" + severity + "] " + message; if (_mWriter != null) { _mWriter.WriteLine(line); _mWriter.Flush(); } else { Console.WriteLine(line); } }
/// <summary> /// 业务事务-完成 /// 访问属性-public=>private /// </summary> private void Complete() { var ctx = _manager.GetContext(); CompleteTransaction(ctx.Transaction); if (ctx.Transaction.Depth == 0) { ctx.EndTime = MilliSecondTimer.CurrentTime(); #region 时间间隔(毫秒计算) ctx.TimeSpanInMilliseconds = MilliSecondTimer.TimeSpanInMilliseconds(ctx.BeginTime, ctx.EndTime); #endregion var log = MessagePrint.PlainTextMessage(ctx); //LOG Exception LogHelper.Instance.Info(log); //Logger.Info(log); // ctx.Transaction = null; // _manager.Dispose(); } }
public StatusUpdateTask(IMessageStatistics mStatistics, AbstractClientConfig c) { try { _mStatistics = mStatistics; config = c; currentProcess = Process.GetCurrentProcess(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); fileVersion = FileVersionInfo.GetVersionInfo(executingAssembly.Location).FileVersion.ToString(); physicalMemory = GetPhysicalMemory(); if (null != currentProcess) { startTime = MilliSecondTimer.ToUnixMilliSeconds(currentProcess.StartTime); } dotNetVersion = Environment.Version.ToString(); if (null != currentProcess) { userName = currentProcess.StartInfo.UserName; } arch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); ntVersion = Environment.OSVersion.Version.Major + "." + Environment.OSVersion.Version.Minor; processorCount = Environment.ProcessorCount; #if NETFULL perfMetricProvider = new DefaultPerformanceMetricProvider(); perfMetricProvider.Initialize(); #endif } catch (Exception ex) { Cat.lastException = ex; } }
public static void Test() { try { const string UNIQUE_ID = "S"; // Number of batches const int N_BATCH = 1024; // Number of transactions in each batch const int BATCH_SIZE = 1000; // Sleep SLEEP_PERIOD ms after sending one batch. const int SLEEP_PERIOD = 50; PerfTestUtil.WriteLine("Batch send test {0} START. N_BATCH[{1}], BATCH_SIZE[{2}] SLEEP_PERIOD[{3}] Sender queue size[{4}]", UNIQUE_ID, N_BATCH, BATCH_SIZE, SLEEP_PERIOD, 1000); ITransaction rootTransaction = Cat.NewTransaction( "Root transaction of batch send test " + UNIQUE_ID + " N_BATCH [" + N_BATCH + "] BATCH_SIZE [" + BATCH_SIZE + "] SLEEP_PERIOD[" + SLEEP_PERIOD + " " + " Sender queue size[" + 1000 + "]", "Root transaction of batch send test"); long start = MilliSecondTimer.UnixNowMilliSeconds(); for (int i = 0; i < N_BATCH; i++) { for (int j = 0; j < BATCH_SIZE; j++) { ITransaction child = Cat.NewTransaction("Child transaction of batch send test " + UNIQUE_ID, ""); child.Status = CatConstants.SUCCESS; child.Complete(); } Thread.Sleep(SLEEP_PERIOD); } rootTransaction.Status = CatConstants.SUCCESS; rootTransaction.Complete(); PerfTestUtil.WriteLine("Batch send test {0} END. Latency[{1} ms]. {2}", UNIQUE_ID, (MilliSecondTimer.UnixNowMilliSeconds() - start), Cat.ToText()); } catch (Exception ex) { PerfTestUtil.WriteLine("Exception occurred in full speed send test:\n " + ex); throw ex; } }
private bool ShouldMerge(BlockingThreadSafeQueue <IMessageTree> trees) { IMessageTree tree; trees.TryPeek(out tree, true); if (tree != null) { long firstTime = tree.Message.Timestamp; // 30 sec const int maxDuration = 1000 * 30; if (MilliSecondTimer.CurrentTimeMicros() / 1000 - firstTime > maxDuration || trees.Count >= MAX_ATOMIC_MESSAGES || trees.Count >= _mClientConfig.MaxQueueSize || trees.EstimatedByteSize >= _mClientConfig.MaxQueueByteSize) { return(true); } } return(false); }
protected AbstractMessage(String type, String name) { _mType = type; _mName = name; TimestampInMicros = MilliSecondTimer.CurrentTimeMicros(); }
protected AbstractMessage(String type, String name) { _mType = type; _mName = name; TimestampInMicros = MilliSecondTimer.UnixNowMicroSeconds(); }
public DefaultPerformanceMetricProvider() { startTime = MilliSecondTimer.ToUnixMilliSeconds(currentProcess.StartTime); }
public static void WriteLine(string format, params object[] args) { Console.WriteLine(MilliSecondTimer.UnixNowMilliSeconds() + " " + String.Format(format, args)); }