Example #1
0
        public AS3AP(string logPath, BenchMarkConfiguration configuration)
        {
            this.configuration = configuration;

            this.logPath = logPath;
            if (!this.logPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                this.logPath += Path.DirectorySeparatorChar;
            }

            string logName = this.logPath + "as3ap_" +
                             System.DateTime.Now.Year.ToString() +
                             System.DateTime.Now.Month.ToString() +
                             System.DateTime.Now.Day.ToString() +
                             System.DateTime.Now.Hour.ToString() +
                             System.DateTime.Now.Minute.ToString() +
                             System.DateTime.Now.Second.ToString() +
                             ".log";

            if (configuration.EnableLogging)
            {
                this.log = new Logger(logName, Mode.OVERWRITE);
            }

            testSuite     = TestSuiteFactory.GetTestSuite(testSuiteType, configuration);
            testSuite.Log = log;

            testSuite.Result   += new ResultEventHandler(OnResult);
            testSuite.Progress += new ProgressEventHandler(OnProgress);
        }
Example #2
0
        public void Run()
        {
            try
            {
                if (this.testSuite.Log != null)
                {
                    testSuite.Log.Simple("Starting as3ap benchmark at: {0} \r\n\r\n", DateTime.Now);
                }

                string[] testSequence = this.configuration.RunSequence.Split(';');

                for (int i = 0; i < testSequence.Length; i++)
                {
                    string[] testType = testSequence[i].Split(':');

                    for (int j = 0; j < testType.Length; j++)
                    {
                        switch (testType[j].ToUpper())
                        {
                        case "SQL87":
                        case "SQL92":
                        {
                            if (this.ProgressMessage != null)
                            {
                                this.ProgressMessage(
                                    this,
                                    new ProgressMessageEventArgs("Running tests using " + testType[j] + " syntax"));
                            }

                            if (this.TestResult != null)
                            {
                                this.TestResult(
                                    this,
                                    new TestResultEventArgs("Running using [" + testType[j] + "] syntax",
                                                            0,
                                                            new TimeSpan(0),
                                                            false));
                            }

                            this.testSuite            = TestSuiteFactory.GetTestSuite(testSuiteType, configuration);
                            this.testSuite.Log        = log;
                            this.testSuite.TupleCount = tupleCount;

                            this.testSuite.Result   += new ResultEventHandler(OnResult);
                            this.testSuite.Progress += new ProgressEventHandler(OnProgress);

                            if (this.testSuite.Log != null)
                            {
                                this.testSuite.Log.Simple("\r\n\"Running tests using {0} syntax\"\r\n", testType[j]);
                            }
                        }
                        break;

                        case "SINGLEUSER":
                        {
                            if (this.configuration.RunCreate)
                            {
                                this.CreateDatabase();
                            }
                            else
                            {
                                this.testSuite.ConnectDatabase();
                                this.testSuite.TupleCount = this.testSuite.CountRows("updates");
                                this.testSuite.DisconnectDatabase();
                            }

                            if (this.ProgressMessage != null)
                            {
                                this.ProgressMessage(this, new ProgressMessageEventArgs("Starting single-user test"));
                            }

                            if (this.testSuite.Log != null)
                            {
                                this.testSuite.Log.Simple("\r\n");
                            }

                            this.testSuite.SingleUserTests();
                        }
                        break;

                        case "MULTIUSER":
                        {
                            if (this.configuration.RunCreate)
                            {
                                this.CreateDatabase();
                            }
                            else
                            {
                                this.testSuite.ConnectDatabase();
                                this.testSuite.TupleCount = this.testSuite.CountRows("updates");
                                this.testSuite.DisconnectDatabase();
                            }

                            /* Start of the multi-user test */
                            this.currentTest = "Preparing multi-user test";
                            this.testSuite.ConnectDatabase();

                            if (this.testSuite.TupleCount != this.testSuite.CountRows("updates"))
                            {
                                this.testSuite.DisconnectDatabase();

                                if (this.testSuite.Log != null)
                                {
                                    this.testSuite.Log.Simple("Invalid data ( Multi user tests )");
                                }
                                throw new InvalidOperationException("Invalid data ( Multi user tests ).");
                            }
                            else
                            {
                                this.testSuite.DisconnectDatabase();

                                if (this.ProgressMessage != null)
                                {
                                    this.ProgressMessage(
                                        this, new ProgressMessageEventArgs("Starting multi-user test"));
                                }

                                int dbSize = dbSize = (4 * this.testSuite.TupleCount * 100) / 1000000;;

                                this.testSuite.MultiUserTests(configuration.UserNumber == 0 ? (int)(dbSize / 4) : configuration.UserNumber);
                            }
                        }
                        break;
                        }
                    }

                    if (i < testSequence.Length)
                    {
                        // Wait 10 seconds before running next benchmark
                        Thread.Sleep(10000);
                    }
                }

                if (this.ProgressMessage != null)
                {
                    this.ProgressMessage(this, new ProgressMessageEventArgs("!!! Finished !!!"));
                }
            }
            catch (Exception ex)
            {
                this.testSuite.DisconnectDatabase();
                this.testSuite.Dispose();

                throw ex;
            }
        }