Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
        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");
        }
        public virtual long GetUpTime()
        {
            if (0 == startTime)
            {
                return(0);
            }

            return(MilliSecondTimer.UnixNowMilliSeconds() - startTime);
        }
Esempio n. 4
0
        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.");
        }
Esempio n. 5
0
        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;
            }
        }
Esempio n. 6
0
        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.UnixNowMilliSeconds() - firstTime > maxDuration ||
                    trees.Count >= MAX_ATOMIC_MESSAGES ||
                    trees.Count >= _mClientConfig.MaxQueueSize ||
                    trees.EstimatedByteSize >= _mClientConfig.MaxQueueByteSize)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 7
0
 public static void WriteLine(string format, params object[] args)
 {
     Console.WriteLine(MilliSecondTimer.UnixNowMilliSeconds() + " " + String.Format(format, args));
 }