Esempio n. 1
0
		/// <summary>
		/// Dumps a test and its snapshots to the performance database
		/// </summary>
		private static void DumpTest(SqlConnection connection, TestData test, IList<Snapshot> snapshots, DateTime timeStamp)
		{
			Console.WriteLine("Dumping results for test \"{0}\"", test.Name);

			double avgManMem = 0;
			double avgUnmanMem = 0;
			double avgMem = 0;

			double normMem = 1.0 / snapshots.Count;

			foreach (Snapshot snapshot in snapshots)
			{
				avgManMem += snapshot.ManagedBytes * normMem;
				avgUnmanMem += snapshot.UnmanagedBytes * normMem;
				avgMem += avgManMem + avgUnmanMem;
			}


			int testId;
			using (SqlCommand cmd = new SqlCommand())
			{
				cmd.Connection = connection;
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.CommandText = "[ADD_MEMORY_TEST]";
				cmd.Parameters.AddWithValue("@NAME", test.Name);
				cmd.Parameters.AddWithValue("@DESCRIPTION", test.Description);
				cmd.Parameters.AddWithValue("@MACHINENAME", g_MachineName);
				cmd.Parameters.AddWithValue("@BRANCH", g_Branch);
				cmd.Parameters.AddWithValue("@CURRENTASSEMBLYVERSION", g_AssemblyVersion);
				cmd.Parameters.AddWithValue("@RELEASEBUILD", g_ReleaseBuild);
				cmd.Parameters.AddWithValue("@RUNDATE", timeStamp);
				cmd.Parameters.AddWithValue("@AVGMANMEM", (long)avgManMem);
				cmd.Parameters.AddWithValue("@AVGUNMANMEM", (long)avgUnmanMem);

				SqlParameter testIdParam = cmd.CreateParameter();
				testIdParam.ParameterName = "result";
				testIdParam.DbType = DbType.Int32;
				testIdParam.Direction = ParameterDirection.ReturnValue;
				cmd.Parameters.Add(testIdParam);

				cmd.ExecuteNonQuery();
				testId = (int)testIdParam.Value;
			}

			DumpSnapshots(connection, snapshots, testId);
		}
Esempio n. 2
0
        /// <summary>
        /// Dumps tests and test snapshots to the performance database
        /// </summary>
        private static void DumpTestResults(TestData[] tests, IList<Snapshot>[] testSnapshots, DateTime timeStamp)
        {
            if (!CanDumpTestResults())
            {
                Console.WriteLine("Errror dumping tests to performance database. Connection not available.");
                return;
            }

			Console.WriteLine();
			Console.WriteLine("Dumping tests to performance database");

			using (SqlConnection connection = new SqlConnection(ConnectionString))
			{
				connection.Open();

				for (int testIndex = 0; testIndex < tests.Length; ++testIndex)
				{
					DumpTest(connection, tests[testIndex], testSnapshots[testIndex], timeStamp);
				}
			}
		}