コード例 #1
0
ファイル: Summariser.cs プロジェクト: CDHDeveloper/NetMeter
        /**
         * Called from a different thread as testStarted() but using the same instance.
         * So synch is needed to fetch the accumulator, and the myName field will already be set up.
         * <p>
         * {@inheritDoc}
         */
        public void TestEnded(String host)
        {
            List <KeyValuePair <String, Totals> > totals = new List <KeyValuePair <String, Totals> >();

            Monitor.Enter(LOCK);
            try
            {
                instanceCount--;
                if (instanceCount <= 0)
                {
                    totals = accumulators.ToList();
                }
            }
            finally
            {
                Monitor.Exit(LOCK);
            }

            // We're not done yet
            if (totals.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <String, Totals> pair in totals)
            {
                String str   = "";
                String name  = pair.Key;
                Totals total = pair.Value;
                // Only print final delta if there were some samples in the delta
                // and there has been at least one sample reported previously
                if (total.delta.getNumSamples() > 0 && total.total.getNumSamples() > 0)
                {
                    str = Format(name, total.delta, "+");
                    if (TOLOG)
                    {
                        log.Info(str);
                    }
                    if (TOCONSOLE)
                    {
                        System.Console.WriteLine(str);
                    }
                }
                total.MoveDelta();
                str = Format(name, total.total, "=");
                if (TOLOG)
                {
                    log.Info(str);
                }
                if (TOCONSOLE)
                {
                    System.Console.WriteLine(str);
                }
            }
        }