public PerformanceController(ILogger <PerformanceController> logger, PerformanceContext context,
                              IConfiguration configuration)
 {
     _context       = context;
     _logger        = logger;
     _configuration = configuration;
 }
Esempio n. 2
0
 public RpsController(ILogger <ThroughputController> logger, PerformanceContext context,
                      IConfiguration configuration)
 {
     _context       = context;
     _logger        = logger;
     _configuration = configuration;
 }
Esempio n. 3
0
        public IPerformanceData CreatePerformanceData(PerformanceContext context)
        {
            var r = requests.Dump();
            var c = completedRequests.Dump();

            return(new HttpPerformanceData("aspnet core", context.TimeRange, r, c));
        }
Esempio n. 4
0
 private static void LoadEntities <T>()
 {
     using (var context = new PerformanceContext())
     {
         context.Database.Log = Console.WriteLine;
         var stopWatch = Stopwatch.StartNew();
         (from p in context.Entities.OfType <T>() select p).ToList();
         Console.WriteLine($"{nameof(T)} query {stopWatch.Elapsed:g}");
     }
 }
Esempio n. 5
0
        public RequestStatistics End(RequestStatisticsType tag, string destination)
        {
            PerformanceContext performanceContext = PerformanceContext.Current;
            long timeTaken    = 0L;
            int  requestCount = 0;

            if (this.begin != null && performanceContext != null)
            {
                timeTaken    = (long)(performanceContext.RequestLatency - this.begin.RequestLatency);
                requestCount = (int)(performanceContext.RequestCount - this.begin.RequestCount);
            }
            if (destination == null)
            {
                return(RequestStatistics.Create(tag, timeTaken, requestCount));
            }
            return(RequestStatistics.Create(tag, timeTaken, requestCount, destination));
        }
Esempio n. 6
0
 private static void SaveEntities()
 {
     Database.SetInitializer(new DropCreateDatabaseAlways <PerformanceContext>());
     using (var context = new PerformanceContext())
     {
         context.Database.Initialize(true);
         const int numberOf = 100;
         context.Entities.AddRange(CreateEntities <Child1>(numberOf));
         context.Entities.AddRange(CreateEntities <Child2>(numberOf));
         context.Entities.AddRange(CreateEntities <Child3>(numberOf));
         context.Entities.AddRange(CreateEntities <Child4>(numberOf));
         context.Entities.AddRange(CreateEntities <Child5>(numberOf));
         var stopWatch = Stopwatch.StartNew();
         context.SaveChanges();
         stopWatch.Stop();
         Console.WriteLine($"Guardar {stopWatch.Elapsed:g}");
     }
 }
 public static object Create(Type type, PerformanceContext perfContext)
 {
     ConstructorInfo ctor;
     if(Constructors.TryGetValue(type, out ctor))
     {
         return InvokeConstructor(ctor, perfContext);
     }
     else if (type.IsSubclassOf(typeof(PerformanceMonitoredService))
         ||type.IsAssignableFrom(typeof(PerformanceMonitoredService)))
     {
         ConstructorInfo newCtor = type.GetConstructor( 
             new[] { typeof(PerformanceContext) }
         );
         if(Constructors.TryAdd(type, newCtor))
         {
             return InvokeConstructor(newCtor, perfContext);
         } else if(Constructors.TryGetValue(type, out ctor))
         {
             return InvokeConstructor(ctor, perfContext);
         }
     }
     throw new ArgumentException(
         $"Expected type inheritable of {typeof(PerformanceMonitoredService).Name}"}",
 public ChartController(PerformanceContext context, IMapper mapper)
 {
     Context = context;
     Mapper  = mapper;
 }
Esempio n. 9
0
 public PerformanceMonitoredService(PerformanceContext perfContext)
 {
 }
 public AchievementController(PerformanceContext context, IMapper mapper)
 {
     Context = context;
     Mapper  = mapper;
 }
 public IndexLibraryController(PerformanceContext context, IMapper mapper)
 {
     Context = context;
     Mapper  = mapper;
 }
Esempio n. 12
0
        public bool Ping()
        {
            base.CheckDisposed();
            bool flag  = false;
            bool flag2 = false;

            this.lastPingAttemptUtc = TimeProvider.UtcNow;
            try
            {
                if (!this.Pinging)
                {
                    lock (this.instanceLock)
                    {
                        if (!this.Pinging)
                        {
                            this.Pinging = true;
                            flag2        = true;
                        }
                    }
                }
                if (flag2)
                {
                    ExTraceGlobals.DatabasePingerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "Attempting XSO ping against database {0}", this.databaseGuid);
                    lock (this.instanceLock)
                    {
                        PerformanceContext performanceContext = default(PerformanceContext);
                        bool flag5 = false;
                        bool flag6 = ExTraceGlobals.DatabasePingerTracer.IsTraceEnabled(TraceType.DebugTrace);
                        if (flag6)
                        {
                            flag5 = NativeMethods.GetTLSPerformanceContext(out performanceContext);
                        }
                        DateTime utcNow = TimeProvider.UtcNow;
                        flag = this.OpenSession();
                        if (flag)
                        {
                            PingerPerfCounterWrapper.PingSuccessful();
                        }
                        else
                        {
                            PingerPerfCounterWrapper.PingFailed();
                        }
                        TimeSpan           timeSpan = TimeProvider.UtcNow - utcNow;
                        PerformanceContext performanceContext2;
                        if (flag6 && flag5 && NativeMethods.GetTLSPerformanceContext(out performanceContext2))
                        {
                            uint  num  = performanceContext2.rpcCount - performanceContext.rpcCount;
                            ulong num2 = performanceContext2.rpcLatency - performanceContext.rpcLatency;
                            ExTraceGlobals.DatabasePingerTracer.TraceDebug((long)this.GetHashCode(), "Ping Stats - Mdb: {0}, Rpc Count: {1}, Rpc Latency: {2}. Elapsed: {3}", new object[]
                            {
                                this.databaseGuid,
                                num,
                                num2,
                                timeSpan
                            });
                        }
                        goto IL_17F;
                    }
                }
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid>((long)this.GetHashCode(), "Could not make ping call against mdb {0} because there is already an outstanding ping.", this.databaseGuid);
                IL_17F :;
            }
            catch (StoragePermanentException arg)
            {
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid, StoragePermanentException>((long)this.GetHashCode(), "Encountered permanent exception acquiring and pinging mdb {0}.  Exception: {1}", this.databaseGuid, arg);
                this.principal = null;
                this.DisposeAccessInfo();
                this.pingerState = MdbSystemMailboxPinger.PingerState.NeedReinitialization;
                PingerPerfCounterWrapper.PingFailed();
            }
            catch (StorageTransientException arg2)
            {
                PingerPerfCounterWrapper.PingFailed();
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid, StorageTransientException>((long)this.GetHashCode(), "Encountered transient exception acquiring and pinging mdb {0}.  Exception: {1}", this.databaseGuid, arg2);
            }
            catch (Exception)
            {
                PingerPerfCounterWrapper.PingFailed();
                throw;
            }
            finally
            {
                if (flag2)
                {
                    lock (this.instanceLock)
                    {
                        this.Pinging = false;
                    }
                }
            }
            return(flag);
        }
Esempio n. 13
0
 public PerformanceInstanceExtension(PerformanceContext perfContext)
 {
     PerformanceContext = perfContext;
 }
Esempio n. 14
0
 public PerformanceInstanceExtension()
 {
     PerformanceContext = new PerformanceContext();
 }