Ejemplo n.º 1
0
 private void AppendCsvRow(string perfLogFile, PerfCsvRow row)
 {
     if (!File.Exists(perfLogFile))
     {
         File.AppendAllText(perfLogFile, row.HeeaderRow() + "\r\n");
     }
     File.AppendAllText(perfLogFile, row.ToCsvString() + "\r\n");
 }
Ejemplo n.º 2
0
 private void ExtractTestNameData(string testName, ref PerfCsvRow csvRow)
 {
     testName               = testName.ToLower();
     csvRow.IsRollback      = testName.Contains("rollback");
     csvRow.TransactionType = testName.Contains("no_transaction") ? "None"
         : testName.Contains("db_transaction") || testName.Contains("dbtransaction") ? "DatabaseTransaction"
         : testName.Contains("_transaction_") ? "TransactionScope"
         : "?";
     csvRow.ContextCount     = testName.Contains("multiple") ? 2 : 1;
     csvRow.ContextTypeCount = testName.Contains("different_contexts") ? 2 : 1;
 }
Ejemplo n.º 3
0
        public void MeasurePerf(Action action, [CallerMemberName] string callerName = null)
        {
            var sw = Stopwatch.StartNew();

            for (int i = 0; i < LoopsCount; i++)
            {
                action();
            }

            Trace.WriteLine($"[{callerName}] elapsed: {sw.Elapsed}");

            var csvRow = new PerfCsvRow()
            {
                TestName  = callerName,
                Loops     = LoopsCount,
                Elapsed   = sw.Elapsed,
                ElapsedMs = sw.ElapsedMilliseconds,
            };

            ExtractTestNameData(callerName, ref csvRow);

            AppendCsvRow(OutFile, csvRow);
        }