Example #1
0
        static void InitializeECommon()
        {
            _message = new byte[int.Parse(ConfigurationManager.AppSettings["MessageSize"])];
            _mode = ConfigurationManager.AppSettings["Mode"];
            _messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]);

            var logContextText = "mode: " + _mode;

            ECommonConfiguration
                .Create()
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .RegisterUnhandledExceptionHandler();

            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(typeof(Program).Name);
            _performanceService = ObjectContainer.Resolve<IPerformanceService>();
            var setting = new PerformanceServiceSetting
            {
                AutoLogging = false,
                StatIntervalSeconds = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.InfoFormat("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, logContextText, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };
            _performanceService.Initialize(_performanceKey, setting);
            _performanceService.Start();
        }
Example #2
0
 public RequestHandler()
 {
     _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);
     _performanceService = ObjectContainer.Resolve<IPerformanceService>();
     var setting = new PerformanceServiceSetting
     {
         AutoLogging = false,
         StatIntervalSeconds = 1,
         PerformanceInfoHandler = x =>
         {
             _logger.InfoFormat("{0}, totalCount: {1}, throughput: {2}, averageThrughput: {3}, rt: {4:F3}ms, averageRT: {5:F3}ms", _performanceService.Name, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
         }
     };
     _performanceService.Initialize(_performanceKey, setting);
     _performanceService.Start();
 }
        public void Initialize(string name, PerformanceServiceSetting setting = null)
        {
            Ensure.NotNullOrEmpty(name, "name");

            if (setting == null)
            {
                _setting = new PerformanceServiceSetting
                {
                    AutoLogging = true,
                    StatIntervalSeconds = 1
                };
            }
            else
            {
                _setting = setting;
            }

            Ensure.Positive(_setting.StatIntervalSeconds, "PerformanceServiceSetting.StatIntervalSeconds");

            _name = name;
            _taskName = name + ".Task";
        }
        public void Initialize(string name, PerformanceServiceSetting setting = null)
        {
            Ensure.NotNullOrEmpty(name, "name");

            if (setting == null)
            {
                _setting = new PerformanceServiceSetting
                {
                    AutoLogging         = true,
                    StatIntervalSeconds = 1
                };
            }
            else
            {
                _setting = setting;
            }

            Ensure.Positive(_setting.StatIntervalSeconds, "PerformanceServiceSetting.StatIntervalSeconds");

            _name     = name;
            _taskName = name + ".Task";
        }