public static string DetailedResults(TestResultGrp resultGrp, string fieldSep, string recordSep)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            //header stuff
            sb.Append(resultGrp.TestName);
            sb.Append(recordSep);
            sb.Append(resultGrp.Motivation);
            sb.Append(recordSep);
            sb.Append(recordSep);

            //results
            TestResult[] Results = resultGrp.Results;
            foreach (TestResult tr in Results)
            {
                sb.Append(tr.TestName); sb.Append(fieldSep);
                sb.Append("Normalised:");       sb.Append(fieldSep);    sb.Append(tr.NormalizedTestDuration);   sb.Append(fieldSep);
                sb.Append("Median:");           sb.Append(fieldSep);    sb.Append(tr.Median);                           sb.Append(fieldSep);
                sb.Append("Mean:");                     sb.Append(fieldSep);    sb.Append(tr.Mean);                                     sb.Append(fieldSep);
                sb.Append("Min:");                      sb.Append(fieldSep);    sb.Append(tr.Min);                                      sb.Append(fieldSep);
                sb.Append("Max:");                      sb.Append(fieldSep);    sb.Append(tr.Max);                                      sb.Append(fieldSep);
                sb.Append("StdDev:");           sb.Append(fieldSep);    sb.Append(tr.StdDev);                           sb.Append(fieldSep);
                sb.Append("Results:");
                foreach (TimeSpan res in tr.TestResults)
                {
                    sb.Append(res);         sb.Append(fieldSep);
                }
                sb.Append(recordSep);
            }
            return(sb.ToString());
        }
        static public void DisplayResults(TestResultGrp Results, Output Display, object[] ConfigSettings)
        {
            if (Display == null)
            {
                throw new ArgumentException("Null Output object is not allowed");
            }
            Output outPut = Display;

            outPut.OutputResults(Results, ConfigSettings);
        }
        protected override void OutputResults(TestResultGrp resultGrp, object[] ConfigSettings)
        {
            TestResult[] Results = resultGrp.Results;
            if (Results == null)
            {
                return;
            }

            ChartOutputForm cd = new ChartOutputForm(Results);

            cd.ShowDialog();
        }
 public static string SummaryResults(TestResultGrp resultGrp, string fieldSep, string recordSep)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     TestResult[] Results         = resultGrp.Results;
     foreach (TestResult tr in Results)
     {
         sb.Append(tr.TestName);
         sb.Append(" Median: ");
         sb.Append(tr.Median);
         sb.Append(recordSep);
     }
     return(sb.ToString());
 }
        protected override void OutputResults(TestResultGrp resultGrp, object[] ConfigSettings)
        {
            if (resultGrp.Results == null)
            {
                return;
            }

            if ((bool)ConfigSettings[0])
            {
                System.Windows.Forms.MessageBox.Show(TestResultFormatter.SummaryResults(resultGrp, "\t", "\n"));
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(TestResultFormatter.DetailedResults(resultGrp, "\t", "\n"));
            }
        }
        public TestResultGrp RunTestDefault()
        {
            foreach (IChannel channel in ChannelServices.RegisteredChannels)
            {
                ChannelServices.UnregisterChannel(channel);
            }
            HttpChannel httpChannel = new HttpChannel();
            TcpChannel  tcpChannel  = new TcpChannel();

            ChannelServices.RegisterChannel(httpChannel);
            ChannelServices.RegisterChannel(tcpChannel);

            TestResultGrp trg = RunTests();

            return(trg);
        }
        public TestResultGrp RunTestSoap()
        {
            foreach (IChannel channel in ChannelServices.RegisteredChannels)
            {
                ChannelServices.UnregisterChannel(channel);
            }
            SoapServerFormatterSinkProvider svr  = new SoapServerFormatterSinkProvider();
            SoapClientFormatterSinkProvider clnt = new SoapClientFormatterSinkProvider();
            HttpChannel httpChannel = new HttpChannel();
            TcpChannel  tcpChannel  = new TcpChannel(null, clnt, svr);

            ChannelServices.RegisterChannel(httpChannel);
            ChannelServices.RegisterChannel(tcpChannel);

            TestResultGrp trg = RunTests();

            return(trg);
        }
        public TestResultGrp ReadTest()
        {
            const int  numberIterations = 1;
            const int  numberTestRuns   = 5;
            TestRunner tr     = new TestRunner(numberIterations, numberTestRuns);
            TestGroup  tgComp = new TestGroup(new TestRunner.TestCase(CompressedRead), new TestRunner.TestCleanup(ReadInit),
                                              new TestRunner.TestCleanup(TestRunner.NoOp), new TestRunner.TestValidity(TestRunner.TestOK));
            TestGroup tgUnComp = new TestGroup(new TestRunner.TestCase(UncompressedRead), new TestRunner.TestCleanup(ReadInit),
                                               new TestRunner.TestCleanup(TestRunner.NoOp), new TestRunner.TestValidity(TestRunner.TestOK));

            tr.AddTestGroup(tgComp);
            tr.AddTestGroup(tgUnComp);

            TestResultGrp ret = tr.RunTests(null);

            File.Delete(_fileName + ".cmp");
            return(ret);
        }
        static public void DisplayResults(TestResultGrp Results, DisplayOption Display,
                                          object[] ConfigSettings)
        {
            Output outPut;

            switch (Display)
            {
            case DisplayOption.MessageBox:
                outPut = new MessageBoxOutput();
                break;

            case DisplayOption.Chart:
                outPut = new ChartOutput();
                break;

            case DisplayOption.File:
                outPut = new FileOutput();
                break;

            default:
                goto case DisplayOption.MessageBox;
            }
            outPut.OutputResults(Results, ConfigSettings);
        }
        protected override void OutputResults(TestResultGrp resultGrp, object[] ConfigSettings)
        {
            TestResult[] Results = resultGrp.Results;

            string procName                = "";
            uint   L2CacheSize             = 0;
            uint   L2CacheSpeed            = 0;
            int    procNo                  = 0;
            ManagementObjectSearcher   mos = new ManagementObjectSearcher("SELECT Name, L2CacheSize, L2CacheSpeed FROM  Win32_Processor");
            ManagementObjectCollection moc = mos.Get();

            foreach (ManagementObject mob in moc)
            {
                ++procNo;
                procName     = mob.Properties["Name"].Value.ToString();
                L2CacheSize  = Convert.ToUInt32(mob.Properties["L2CacheSize"].Value);
                L2CacheSpeed = Convert.ToUInt32(mob.Properties["L2CacheSpeed"].Value);
            }


            if (Results == null)
            {
                return;
            }

            string xmlFileName = (string)ConfigSettings[0];

            if (xmlFileName == String.Empty)
            {
                xmlFileName = "c:\\" + resultGrp.TestName + ".xml";
            }
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8);
            writer.WriteStartElement("testresults");
            writer.WriteAttributeString("Name", resultGrp.TestName);
            if (resultGrp.Motivation != String.Empty)
            {
                writer.WriteAttributeString("Motivation", resultGrp.Motivation);
            }
            writer.WriteAttributeString("TestTime", DateTime.UtcNow.ToString("r"));
            writer.WriteAttributeString("MachineName", System.Environment.MachineName);
            writer.WriteAttributeString("CLR_Version", System.Environment.Version.ToString());
            writer.WriteAttributeString("OS", System.Environment.OSVersion.ToString());
            writer.WriteAttributeString("NoProcessors", procNo.ToString());
            writer.WriteAttributeString("ProcName", procName);
            writer.WriteAttributeString("L2CacheSize_Kilobytes", L2CacheSize.ToString());
            writer.WriteAttributeString("L2CacheSpeed_MegaHertz", L2CacheSpeed.ToString());
            foreach (DotNetPerformance.TestResult tr in Results)
            {
                writer.WriteStartElement("testresult");
                writer.WriteAttributeString("Name", tr.TestName);
                writer.WriteAttributeString("Min", tr.Min.TotalMilliseconds.ToString());
                writer.WriteAttributeString("Median", tr.Median.TotalMilliseconds.ToString());
                writer.WriteAttributeString("Max", tr.Max.TotalMilliseconds.ToString());
                writer.WriteAttributeString("NormalizedTestDuration", tr.NormalizedTestDuration.ToString());
                foreach (TimeSpan ts in tr.TestResults)
                {
                    writer.WriteElementString("testrun", ts.TotalMilliseconds.ToString());
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.Close();
            System.Diagnostics.Process.Start(xmlFileName);
        }
 protected abstract void OutputResults(TestResultGrp Results,
                                       object[] ConfigSettings);