private void SaveOperationThreshold()
        {
            Guid MiniProfilerId;

            MiniProfilerId = PerformanceLabs.MiniProfiler.Id;

            //MiniProfiler.Settings.Storage.Save(PerformanceLabs.MiniProfiler);

            Type t = (PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext) ? typeof(PerformanceLabsDBContext) : typeof(Test_PerformanceLabsDBContext);

            using (IPerformanceDBProxy context = (IPerformanceDBProxy)Activator.CreateInstance(t))
            {
                //ParentId = (from mpt in context.MiniProfilerTimings
                //            join mp in context.MiniProfilers
                //            on mpt.MiniProfilerId equals mp.Id
                //            where mpt.Name != null && mpt.Name == OperationName
                //            orderby mp.Started descending, mpt.RowId descending
                //            select mpt.Id).First();

                MiniProfilerOperationThreshold mmpThreshold = new MiniProfilerOperationThreshold()
                {
                    MiniProfilerId           = MiniProfilerId,
                    OperationName            = OperationName,
                    ParentId                 = null,
                    ThresholdOperationTiming = ThresholdOperationTiming
                };

                context.MiniProfilerOperationThresholds.Add(mmpThreshold);
                context.SaveChanges();
            }
        }
 public static void SaveToDataBase()
 {
     if (DurationMilliseconds > TrivialDurationThresholdMillisecondsStopWatch)
     {
         Type t = (PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext) ? typeof(PerformanceLabsDBContext) : typeof(Test_PerformanceLabsDBContext);
         using (IPerformanceDBProxy context = (IPerformanceDBProxy)Activator.CreateInstance(t))
         {
             var parentId = (from swProfiler in context.StopWatchProfilers
                             orderby swProfiler.Started descending
                             select swProfiler.RowId).First();
             if (parentId != 0)
             {
                 StopWatchProfilerTiming swProfilerTiming = new StopWatchProfilerTiming()
                 {
                     ParentId                 = parentId,
                     Name                     = OperationName,
                     MethodRunCounts          = NumOfInvocations,
                     DurationMilliseconds     = DurationMilliseconds,
                     AvgDurationMilliseconds  = AvgDurationMilliseconds,
                     ThresholdOperationTiming = ThresholdOperationTiming
                 };
                 context.StopWatchProfilerTimings.Add(swProfilerTiming);
                 context.SaveChanges();
             }
         }
     }
 }
Ejemplo n.º 3
0
        public void DropDataBase()
        {
            SqlConnection.ClearAllPools();
            Type t = (PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext) ? typeof(PerformanceLabsDBContext) : typeof(Test_PerformanceLabsDBContext);

            using (IPerformanceDBProxy context = (IPerformanceDBProxy)Activator.CreateInstance(t))
            {
                context.Database.Delete();
            }
        }
Ejemplo n.º 4
0
        private void EnsureDataBaseExists()
        {
            Type t = (PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext) ? typeof(PerformanceLabsDBContext) : typeof(Test_PerformanceLabsDBContext);

            using (IPerformanceDBProxy context = (IPerformanceDBProxy)Activator.CreateInstance(t))
            {
                context.Database.CreateIfNotExists();
                //if (context.Database.Exists())
                //{
                //    context.Database.ExecuteSqlCommand(PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext ? PerformanceLabsConfigurations.MakeLoginCredentials : PerformanceLabsConfigurations.MakeLoginCredentialsTestDB);
                //}
            }
        }
        public static void StartProfiler()
        {
            Type t = (PerformanceLabsConfigurations.contextType == PerformanceLabDBContextType.MainContext) ? typeof(PerformanceLabsDBContext) : typeof(Test_PerformanceLabsDBContext);

            using (IPerformanceDBProxy context = (IPerformanceDBProxy)Activator.CreateInstance(t))
            {
                StopWatchProfiler swProfiler = new StopWatchProfiler()
                {
                    ProfilerName = ProfilerName,
                    Started      = DateTime.UtcNow,
                    MachineName  = MachineName,
                    User         = User,
                    TrivialDurationThresholdMilliseconds = TrivialDurationThresholdMillisecondsStopWatch
                };

                context.StopWatchProfilers.Add(swProfiler);
                context.SaveChanges();
            }
        }