public void Test_Empty_Session() { using (SqlTraceReader reader = new SqlTraceReader()) { reader.Start(TestEnvironment.MasterConnectionString, TestEnvironment.TracePath, TraceColumns.All); // summary SqlCounters summary = reader.ReadSummaryReport(); Assert.Zero(summary.Requests); Console.WriteLine("Summary of empty session is " + summary); // details. Summary query above should not be present in details report below. var details = reader.ReadDetailsReport(); CollectionAssert.IsEmpty(details, "Details Collection"); Assert.Zero(details.Summary.Requests); CollectionAssert.IsEmpty(details.GroupByApplication(), "Groups by application"); reader.Stop(); reader.Dispose(); } }
public void Exec1(StressCounters counters) { SqlTraceReader rdr = new SqlTraceReader(); try { var connection = ConnectionFactory(); connection.Open(); if (UseTrace) { // int? spid = SqlServerUtils.GetCurrentSpid(connection); int?spid = connection.Manage().CurrentSPID; rdr.Start( TestEnvironment.MasterConnectionString, TestEnvironment.TracePath, TraceColumns.None, TraceRowFilter.CreateByServerProcess(spid.Value) ); } Work(connection); connection.Close(); if (UseTrace) { rdr.Stop(); var summary = rdr.ReadSummaryReport(); counters.Server_CPU += summary.CPU; counters.Server_Duration += summary.Duration; counters.Server_Reads += summary.Reads; counters.Server_Writes += summary.Writes; } } finally { rdr.Dispose(); } }