System.Diagnostics.Stopwatch.Stop()

Here are the examples of the csharp api System.Diagnostics.Stopwatch.Stop() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5099 Examples 7

19 View Source File : Helper.cs
License : MIT License
Project Creator : 0ffffffffh

public void Time(string msg)
        {
            sw.Stop();
            Log.Info(msg + " took " + sw.Elapsed.ToString());
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 0x1000000

private static async Task ExecScenarioAll(IScenario scenario, string msSqlConnectionString, string pgSqlConnectionString, string mySqlConnectionString)
        {
            Stopwatch stopwatch = new Stopwatch();

            Console.WriteLine();
            Console.WriteLine("-MS SQL Test-------");
            stopwatch.Restart();
            await ExecMsSql(scenario, msSqlConnectionString);
            stopwatch.Stop();
            Console.WriteLine($"-MS SQL Test End: {stopwatch.ElapsedMilliseconds} ms");

            Console.WriteLine("-Postgres Test-----");
            stopwatch.Start();
            await ExecNpgSql(scenario, pgSqlConnectionString);
            stopwatch.Stop();
            Console.WriteLine($"-Postgres Test End: {stopwatch.ElapsedMilliseconds} ms");

            Console.WriteLine();
            Console.WriteLine("-MY SQL Test-------");
            stopwatch.Restart();
            await ExecMySql(scenario, mySqlConnectionString);
            stopwatch.Stop();
            Console.WriteLine($"-MY SQL Test End: {stopwatch.ElapsedMilliseconds} ms");
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_OldWay()
        {
            var sw = Stopwatch.StartNew();

            Task<int> get1 = Get1();
            Task<int> get2 = Get2();
            Task<string> get3Str = Get3Str();
            Task<int> get4 = Get4();

            await Task.WhenAll(get1, get2, get3Str, get4);

            var result = get1.Result + get2.Result + int.Parse(get3Str.Result) + get4.Result;


            sw.Stop();

            replacedert.AreEqual(9, result);
            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs + LagMs);
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_ParallelOnly()
        {
            var sw = Stopwatch.StartNew();

            var result = await
                from val1  in Get1().AsParallel()
                from val2  in Get2().AsParallel()
                from val3S in Get3Str().AsParallel()
                from val4  in Get4().AsParallel()
                select val1 + val2 + int.Parse(val3S) + val4;


            sw.Stop();

            replacedert.AreEqual(9, result);
            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs + LagMs);
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_SequentialAndLet()
        {
            var sw = Stopwatch.StartNew();

            var result = await
                from one in Get1().AsParallel()

                let oneA = one

                from two in Get2().AsParallel()
                from freeStr in Get3Str().AsParallel()

                let free = int.Parse(freeStr)//Intermediate expr 

                from eight in  Add5(free).replacedequential()//Here all the previous results can be used

                from oneB in Get1().AsParallel()
                from twoA in Get2().AsParallel()
                
                from six in Add5(oneB).replacedequential()//Here all the previous results can be used 
                
                select one + oneA + two + int.Parse(freeStr) + free + eight + oneB + twoA + six;


            sw.Stop();

            replacedert.AreEqual(27, result);
            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs*3);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs*3 + LagMs);
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_ParallelAndLet()
        {
            var sw = Stopwatch.StartNew();

            var result = await
                from one in Get1().AsParallel()

                let oneA = one

                from two in Get2().AsParallel()
                from freeStr in Get3Str().AsParallel()

                let free = int.Parse(freeStr)//Intermediate expr 

                from oneB in Get1().AsParallel()
                from twoA in Get2().AsParallel()
                
                select one + oneA + two + int.Parse(freeStr) + free + oneB + twoA;


            sw.Stop();

            replacedert.AreEqual(13, result);
            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs + LagMs);
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_ErrorInSelect()
        {
            var sw = Stopwatch.StartNew();

            var task =
                from val1 in Get1().AsParallel()
                from val2 in Get2().AsParallel()
                from val4 in Get4().AsParallel()

                select val1 == 1 ? throw new Exception("This is a test error #2") : val1 + val2  + val4;

            Exception exception = null;
            try
            {
                await task;
            }
            catch (Exception e)
            {
                exception = e;
            }

            replacedert.NotNull(exception);
            replacedert.AreEqual("This is a test error #2", exception.Message);


            sw.Stop();

            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs + LagMs);
        }

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public async Task Test_Error()
        {
            var sw = Stopwatch.StartNew();

            var task =
                from val1 in Get1().AsParallel()
                from val2 in Get2().AsParallel()
                from err in Error(1).AsParallel()
                from val4 in Get4().AsParallel()
                from error3 in Error(3).replacedequential() 
                from err2 in Error(2).AsParallel()
                select val1 + val2  + val4;

            Exception exception = null;
            try
            {
                await task;
            }
            catch (Exception e)
            {
                exception = e;
            }

            replacedert.NotNull(exception);
            replacedert.AreEqual("This is a test error #1", exception.Message);


            sw.Stop();

            replacedert.GreaterOrEqual(sw.ElapsedMilliseconds, TimeSlotMs);
            replacedert.Less(sw.ElapsedMilliseconds, TimeSlotMs + LagMs);
        }

19 View Source File : CommandExecuteMonitor.cs
License : MIT License
Project Creator : 1100100

private TResult SyncCommandExecuteMonitor<TResult>(string methodName, string sql, object param, Func<TResult> func)
        {
            var sw = Stopwatch.StartNew();
            try
            {
                return func();
            }
            finally
            {
                sw.Stop();
                if (sw.ElapsedMilliseconds > MonitorConfiguration.SlowCriticalValue)
                {
                    SlowCommandNotification(methodName, sql, param, sw.ElapsedMilliseconds);
                }
            }
        }

19 View Source File : CommandExecuteMonitor.cs
License : MIT License
Project Creator : 1100100

private async Task<TResult> AsyncCommandExecuteMonitor<TResult>(string methodName, string sql, object param, Func<Task<TResult>> func)
        {
            var sw = Stopwatch.StartNew();
            try
            {
                return await func();
            }
            finally
            {
                sw.Stop();
                if (sw.ElapsedMilliseconds > MonitorConfiguration.SlowCriticalValue)
                {
                    SlowCommandNotification(methodName, sql, param, sw.ElapsedMilliseconds);
                }
            }
        }

19 View Source File : CommandExecuteMonitor.cs
License : MIT License
Project Creator : 1100100

private void SyncCommandExecuteMonitor(string methodName, string sql, object param, Action action)
        {
            var sw = Stopwatch.StartNew();
            try
            {
                action();
            }
            finally
            {
                sw.Stop();
                if (sw.ElapsedMilliseconds > MonitorConfiguration.SlowCriticalValue)
                {
                    SlowCommandNotification(methodName, sql, param, sw.ElapsedMilliseconds);
                }
            }
        }

19 View Source File : CommandExecuteMonitor.cs
License : MIT License
Project Creator : 1100100

private async Task AsyncCommandExecuteMonitor(string methodName, string sql, object param, Func<Task> action)
        {
            var sw = Stopwatch.StartNew();
            try
            {
                await action();
            }
            finally
            {
                sw.Stop();
                if (sw.ElapsedMilliseconds > MonitorConfiguration.SlowCriticalValue)
                {
                    SlowCommandNotification(methodName, sql, param, sw.ElapsedMilliseconds);
                }
            }
        }

19 View Source File : MelonMain.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

internal void Set(bool val = false) {
#if AGGRESSIVE_TACTICS
            //IL2CPP.ResolveICall<intIntPtrDelegate>("UnityEngine.QualitySettings::set_vSyncCount")(0);
            var mods = AppDomain.CurrentDomain.Getreplacedemblies();
            GC = GCTime();
            MelonCoroutines.Start(GC);
#else
            var mods = MelonHandler.Mods.Select(a=>a.replacedembly).ToArray();
#endif

            if (!val) return;

            var sw = new Stopwatch();
            sw.Start();
            var methodCount = 0;
            
            #region RuntimeHelpers
            
            for (var i = 0; i < mods.Count(); i++) {
                var asm = mods[i];
                var types = asm.GetTypes();
                for (var j = 0; j < types.Length; j++)
                    try {
                        var type = types[j];
                        var methods = AccessTools.GetDeclaredMethods(type);
                        for (var k = 0; k < methods.Count; k++) {
                            RuntimeHelpers.PrepareMethod(methods[k].MethodHandle);
                            methodCount += 1;
                        }
                    } catch {}
            }

            #endregion
            
            sw.Stop();
            MelonLogger.Msg($"Optimized {methodCount:N0} methods in {sw.Elapsed.Milliseconds:N0} milliseconds!");
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Main(string[] args)
        {
            RedisHelper.Initialization(new CSRedis.CSRedisClient("127.0.0.1:6379,asyncPipeline=true,preheat=100,poolsize=100"));
            cli.Set("TestMGet_null1", "");
            RedisHelper.Set("TestMGet_null1", "");
            sedb.StringSet("TestMGet_string1", String);
            ThreadPool.SetMinThreads(10001, 10001);
            Stopwatch sw = new Stopwatch();
            var tasks = new List<Task>();
            var results = new ConcurrentQueue<string>();

            cli.FlushDb();
            while (results.TryDequeue(out var del)) ;
            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                sedb.StringSet(tmp, String);
                var val = sedb.StringGet(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("StackExchange(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    sedb.StringSet(tmp, String);
                    var val = sedb.StringGet(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("StackExchange(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            Task.Run(async () =>
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    await sedb.StringSetAsync(tmp, String);
                    var val = await sedb.StringGetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }).Wait();
            sw.Stop();
            Console.WriteLine("StackExchangeAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(async () =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    await sedb.StringSetAsync(tmp, String);
                    var val = await sedb.StringGetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("StackExchangeAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();


            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                cli.Set(tmp, String);
                var val = cli.Get(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("FreeRedis(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    cli.Set(tmp, String);
                    var val = cli.Get(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("FreeRedis(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            Task.Run(async () =>
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    await cli.SetAsync(tmp, String);
                    var val = await cli.GetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }).Wait();
            sw.Stop();
            Console.WriteLine("FreeRedisAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            //FreeRedis.Internal.AsyncRedisSocket.sb.Clear();
            //FreeRedis.Internal.AsyncRedisSocket.sw.Start();
            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(async () =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    await cli.SetAsync(tmp, String);
                    var val = await cli.GetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            //var sbstr = FreeRedis.Internal.AsyncRedisSocket.sb.ToString()
            //sbstr = sbstr + sbstr.Split("\r\n").Length + "条消息 ;
            Console.WriteLine("FreeRedisAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            using (var pipe = cli.StartPipe())
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    pipe.Set(tmp, String);
                    var val = pipe.Get(tmp);
                }
                var vals = pipe.EndPipe();
                for (var a = 1; a < 200000; a += 2)
                {
                    var val = vals[a].ToString();
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }
            sw.Stop();
            Console.WriteLine("FreeRedisPipeline(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            //sw.Reset();
            //sw.Start();
            //for (var a = 0; a < 100000; a++)
            //    cli.Call(new CommandPacket("SET").Input("TestMGet_string1").InputRaw(String));
            //sw.Stop();
            //Console.WriteLine("FreeRedis2: " + sw.ElapsedMilliseconds + "ms");
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            //sw.Reset();
            //sw.Start();
            //for (var a = 0; a < 100000; a++)
            //{
            //    using (var rds = cli.GetTestRedisSocket())
            //    {
            //        var cmd = new CommandPacket("SET").Input("TestMGet_string1").InputRaw(String);
            //        rds.Write(cmd);
            //        cmd.Read<string>();
            //    }
            //}
            //sw.Stop();
            //Console.WriteLine("FreeRedis4: " + sw.ElapsedMilliseconds + "ms");
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();


            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                RedisHelper.Set(tmp, String);
                var val = RedisHelper.Get(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("CSRedisCore(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    RedisHelper.Set(tmp, String);
                    var val = RedisHelper.Get(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("CSRedisCore(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            Task.Run(async () =>
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    await RedisHelper.SetAsync(tmp, String);
                    var val = await RedisHelper.GetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }).Wait();
            sw.Stop();
            Console.WriteLine("CSRedisCoreAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(async () =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    await RedisHelper.SetAsync(tmp, String);
                    var val = await RedisHelper.GetAsync(tmp);
                    //if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("CSRedisCoreAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            while (results.TryDequeue(out var del)) ;
            cli.FlushDb();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Main(string[] args)
        {

            sedb.StringSet("key1", (string)null);

            var val111 = sedb.StringGet("key1");














            RedisHelper.Initialization(new CSRedis.CSRedisClient("127.0.0.1:6379,asyncPipeline=true,preheat=100,poolsize=100"));
            cli.Set("TestMGet_null1", "");
            RedisHelper.Set("TestMGet_null1", "");
            sedb.StringSet("TestMGet_string1", String);
            ThreadPool.SetMinThreads(10001, 10001);
            Stopwatch sw = new Stopwatch();
            var tasks = new List<Task>();
            var results = new ConcurrentQueue<string>();

            cli.FlushDb();
            results.Clear();
            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                sedb.StringSet(tmp, String);
                var val = sedb.StringGet(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("StackExchange(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    sedb.StringSet(tmp, String);
                    var val = sedb.StringGet(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("StackExchange(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            Task.Run(async () =>
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    await sedb.StringSetAsync(tmp, String);
                    var val = await sedb.StringGetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }).Wait();
            sw.Stop();
            Console.WriteLine("StackExchangeAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(async () =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    await sedb.StringSetAsync(tmp, String);
                    var val = await sedb.StringGetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("StackExchangeAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            results.Clear();
            cli.FlushDb();


            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                cli.Set(tmp, String);
                var val = cli.Get(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("FreeRedis(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    cli.Set(tmp, String);
                    var val = cli.Get(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("FreeRedis(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            //sw.Reset();
            //sw.Start();
            //Task.Run(async () =>
            //{
            //    for (var a = 0; a < 100000; a++)
            //    {
            //        var tmp = Guid.NewGuid().ToString();
            //        await cli.SetAsync(tmp, String);
            //        var val = await cli.GetAsync(tmp);
            //        if (val != String) throw new Exception("not equal");
            //        results.Enqueue(val);
            //    }
            //}).Wait();
            //sw.Stop();
            //Console.WriteLine("FreeRedisAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            //tasks.Clear();
            //results.Clear();
            //cli.FlushDb();

            //FreeRedis.Internal.AsyncRedisSocket.sb.Clear();
            //FreeRedis.Internal.AsyncRedisSocket.sw.Start();
            //sw.Reset();
            //sw.Start();
            //tasks = new List<Task>();
            //for (var a = 0; a < 100000; a++)
            //{
            //    tasks.Add(Task.Run(async () =>
            //    {
            //        var tmp = Guid.NewGuid().ToString();
            //        await cli.SetAsync(tmp, String);
            //        var val = await cli.GetAsync(tmp);
            //        if (val != String) throw new Exception("not equal");
            //        results.Enqueue(val);
            //    }));
            //}
            //Task.WaitAll(tasks.ToArray());
            //sw.Stop();
            ////var sbstr = FreeRedis.Internal.AsyncRedisSocket.sb.ToString()
            ////sbstr = sbstr + sbstr.Split("\r\n").Length + "条消息 ;
            //Console.WriteLine("FreeRedisAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            //tasks.Clear();
            //results.Clear();
            //cli.FlushDb();

            sw.Reset();
            sw.Start();
            using (var pipe = cli.StartPipe())
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    pipe.Set(tmp, String);
                    var val = pipe.Get(tmp);
                }
                var vals = pipe.EndPipe();
                for (var a = 1; a < 200000; a += 2)
                {
                    var val = vals[a].ToString();
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }
            sw.Stop();
            Console.WriteLine("FreeRedisPipeline(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            //sw.Reset();
            //sw.Start();
            //for (var a = 0; a < 100000; a++)
            //    cli.Call(new CommandPacket("SET").Input("TestMGet_string1").InputRaw(String));
            //sw.Stop();
            //Console.WriteLine("FreeRedis2: " + sw.ElapsedMilliseconds + "ms");
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            //sw.Reset();
            //sw.Start();
            //for (var a = 0; a < 100000; a++)
            //{
            //    using (var rds = cli.GetTestRedisSocket())
            //    {
            //        var cmd = new CommandPacket("SET").Input("TestMGet_string1").InputRaw(String);
            //        rds.Write(cmd);
            //        cmd.Read<string>();
            //    }
            //}
            //sw.Stop();
            //Console.WriteLine("FreeRedis4: " + sw.ElapsedMilliseconds + "ms");
            tasks.Clear();
            results.Clear();
            cli.FlushDb();


            sw.Reset();
            sw.Start();
            for (var a = 0; a < 100000; a++)
            {
                var tmp = Guid.NewGuid().ToString();
                RedisHelper.Set(tmp, String);
                var val = RedisHelper.Get(tmp);
                if (val != String) throw new Exception("not equal");
                results.Enqueue(val);
            }
            sw.Stop();
            Console.WriteLine("CSRedisCore(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(() =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    RedisHelper.Set(tmp, String);
                    var val = RedisHelper.Get(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("CSRedisCore(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            Task.Run(async () =>
            {
                for (var a = 0; a < 100000; a++)
                {
                    var tmp = Guid.NewGuid().ToString();
                    await RedisHelper.SetAsync(tmp, String);
                    var val = await RedisHelper.GetAsync(tmp);
                    if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }
            }).Wait();
            sw.Stop();
            Console.WriteLine("CSRedisCoreAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
            tasks.Clear();
            results.Clear();
            cli.FlushDb();

            sw.Reset();
            sw.Start();
            tasks = new List<Task>();
            for (var a = 0; a < 100000; a++)
            {
                tasks.Add(Task.Run(async () =>
                {
                    var tmp = Guid.NewGuid().ToString();
                    await RedisHelper.SetAsync(tmp, String);
                    var val = await RedisHelper.GetAsync(tmp);
                    //if (val != String) throw new Exception("not equal");
                    results.Enqueue(val);
                }));
            }
            Task.WaitAll(tasks.ToArray());
            sw.Stop();
            Console.WriteLine("CSRedisCoreAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count + "\r\n");
            tasks.Clear();
            results.Clear();
            cli.FlushDb();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Main(string[] args)
        {

            var info = cli.Info();
            var info1 = cli.Info("server");

            RedisHelper.Initialization(new CSRedis.CSRedisClient("127.0.0.1:6379,database=2"));
            cli.Set("TestMGet_null1", String);
            RedisHelper.Set("TestMGet_null1", String);
            sedb.StringSet("TestMGet_string1", String);

            Stopwatch sw = new Stopwatch();
            sw.Start();
            cli.Set("TestMGet_string1", String);
            cli.Set("TestMGet_bytes1", Bytes);
            cli.Set("TestMGet_string2", String);
            cli.Set("TestMGet_bytes2", Bytes);
            cli.Set("TestMGet_string3", String);
            cli.Set("TestMGet_bytes3", Bytes);
            sw.Stop();
            Console.WriteLine("FreeRedis: " + sw.ElapsedMilliseconds + "ms");

            sw.Reset();
            sw.Start();
            cli.Set("TestMGet_string1", String);
            cli.Set("TestMGet_bytes1", Bytes);
            cli.Set("TestMGet_string2", String);
            cli.Set("TestMGet_bytes2", Bytes);
            cli.Set("TestMGet_string3", String);
            cli.Set("TestMGet_bytes3", Bytes);
            sw.Stop();
            Console.WriteLine("FreeRedis: " + sw.ElapsedMilliseconds + "ms");

            sw.Reset();
            sw.Start();
            RedisHelper.Set("TestMGet_string1", String);
            RedisHelper.Set("TestMGet_bytes1", Bytes);
            RedisHelper.Set("TestMGet_string2", String);
            RedisHelper.Set("TestMGet_bytes2", Bytes);
            RedisHelper.Set("TestMGet_string3", String);
            RedisHelper.Set("TestMGet_bytes3", Bytes);
            sw.Stop();
            Console.WriteLine("CSRedisCore: " + sw.ElapsedMilliseconds + "ms");

            sw.Reset();
            sw.Start();
            sedb.StringSet("TestMGet_string1", String);
            sedb.StringSet("TestMGet_bytes1", Bytes);
            sedb.StringSet("TestMGet_string2", String);
            sedb.StringSet("TestMGet_bytes2", Bytes);
            sedb.StringSet("TestMGet_string3", String);
            sedb.StringSet("TestMGet_bytes3", Bytes);
            sw.Stop();
            Console.WriteLine("StackExchange: " + sw.ElapsedMilliseconds + "ms");

        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Main(string[] args)
        {
            //预热
            cli.Set(Guid.NewGuid().ToString(), "我也不知道为什么刚刚好十五个字");
            sedb.StringSet(Guid.NewGuid().ToString(), "我也不知道为什么刚刚好十五个字");

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            for (int i = 0; i < 10000; i++)
            {
                var tmp = Guid.NewGuid().ToString();
                cli.Set(tmp, "我也不知道为什么刚刚好十五个字");
                var val = cli.Get(tmp);
                if (val != "我也不知道为什么刚刚好十五个字") throw new Exception("not equal");
            }

            stopwatch.Stop();
            Console.WriteLine("FreeRedis:"+stopwatch.ElapsedMilliseconds);

            //stopwatch.Restart();
            // csredis 会出现连接不能打开的情况
            //for (int i = 0; i < 100; i++)
            //{
            //    var tmp = Guid.NewGuid().ToString();
            //    csredis.Set(tmp, "我也不知道为什么刚刚好十五个字");
            //    _ = csredis.Get(tmp);
            //}

            //stopwatch.Stop();
            //Console.WriteLine("csredis:" + stopwatch.ElapsedMilliseconds);

            stopwatch.Restart();

            for (int i = 0; i < 10000; i++)
            {
                var tmp = Guid.NewGuid().ToString();
                sedb.StringSet(tmp, "我也不知道为什么刚刚好十五个字");
                var val = sedb.StringGet(tmp);
                if (val != "我也不知道为什么刚刚好十五个字") throw new Exception("not equal");
            }

            stopwatch.Stop();
            Console.WriteLine("Seredis:" + stopwatch.ElapsedMilliseconds);

            cli.Subscribe("abc", (chan, msg) =>
            {
                Console.WriteLine($"FreeRedis {chan} => {msg}");
            });

            seredis.GetSubscriber().Subscribe("abc", (chan, msg) =>
            {
                Console.WriteLine($"Seredis {chan} => {msg}");
            });
            Console.ReadKey();

            return;
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Main(string[] args)
        {
            //预热
            cli.Set(Guid.NewGuid().ToString(), "我也不知道为什么刚刚好十五个字");

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            for (int i = 0; i < 10000; i++)
            {
                var tmp = Guid.NewGuid().ToString();
                cli.Set(tmp, "我也不知道为什么刚刚好十五个字");
                var val = cli.Get(tmp);
                if (val != "我也不知道为什么刚刚好十五个字") throw new Exception("not equal");
            }

            stopwatch.Stop();
            Console.WriteLine("FreeRedis:" + stopwatch.ElapsedMilliseconds);
        }

19 View Source File : RedisClient.cs
License : MIT License
Project Creator : 2881099

internal protected virtual T LogCall<T>(CommandPacket cmd, Func<T> func)
        {
            cmd.Prefix(Prefix);
            var isnotice = this.Notice != null;
            if (isnotice == false && this.Interceptors.Any() == false) return func();
            Exception exception = null;

            T ret = default(T);
            var isaopval = false;
            IInterceptor[] aops = new IInterceptor[this.Interceptors.Count + (isnotice ? 1 : 0)];
            Stopwatch[] aopsws = new Stopwatch[aops.Length];
            for (var idx = 0; idx < aops.Length; idx++)
            {
                aopsws[idx] = new Stopwatch();
                aopsws[idx].Start();
                aops[idx] = isnotice && idx == aops.Length - 1 ? new NoticeCallInterceptor(this) : this.Interceptors[idx]?.Invoke();
                var args = new InterceptorBeforeEventArgs(this, cmd, typeof(T));
                aops[idx].Before(args);
                if (args.ValueIsChanged && args.Value is T argsValue)
                {
                    isaopval = true;
                    ret = argsValue;
                }
            }
            try
            {
                if (isaopval == false) ret = func();
                return ret;
            }
            catch (Exception ex)
            {
                exception = ex;
                throw;
            }
            finally
            {
                for (var idx = 0; idx < aops.Length; idx++)
                {
                    aopsws[idx].Stop();
                    var args = new InterceptorAfterEventArgs(this, cmd, typeof(T), ret, exception, aopsws[idx].ElapsedMilliseconds);
                    aops[idx].After(args);
                }
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Update(StringBuilder sb, int forTime, int size) {
			Stopwatch sw = new Stopwatch();

			var songs = fsql.Select<Song>().Limit(size).ToList();
			sw.Restart();
			for (var a = 0; a < forTime; a++) {
				fsql.Update<Song>().SetSource(songs).ExecuteAffrows();
			}
			sw.Stop();
			sb.AppendLine($"FreeSql Update {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms");

			songs = sugar.Queryable<Song>().Take(size).ToList();
			sw.Restart();
			Exception sugarEx = null;
			try {
				for (var a = 0; a < forTime; a++)
					sugar.Updateable(songs).ExecuteCommand();
			} catch (Exception ex) {
				sugarEx = ex;
			}
			sw.Stop();
			sb.AppendLine($"SqlSugar Update {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms" + (sugarEx != null ? $"成绩无效,错误:{sugarEx.Message}" : ""));

			using (var db = new SongContext()) {
				songs = db.Songs.Take(size).AsNoTracking().ToList();
			}
			sw.Restart();
			for (var a = 0; a < forTime; a++) {

				using (var db = new SongContext()) {
					//db.Configuration.AutoDetectChangesEnabled = false;
					db.Songs.UpdateRange(songs.ToArray());
					db.SaveChanges();
				}
			}
			sw.Stop();
			sb.AppendLine($"EFCore Update {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms\r\n");
		}

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Insert(StringBuilder sb, int forTime, int size) {
			var songs = Enumerable.Range(0, size).Select(a => new Song {
				Create_time = DateTime.Now,
				Is_deleted = false,
				replacedle = $"Insert_{a}",
				Url = $"Url_{a}"
			});

			//预热
			fsql.Insert(songs.First()).ExecuteAffrows();
			sugar.Insertable(songs.First()).ExecuteCommand();
			using (var db = new SongContext()) {
				//db.Configuration.AutoDetectChangesEnabled = false;
				db.Songs.AddRange(songs.First());
				db.SaveChanges();
			}
			Stopwatch sw = new Stopwatch();

			sw.Restart();
			for (var a = 0; a < forTime; a++) {
				fsql.Insert(songs).ExecuteAffrows();
			}
			sw.Stop();
			sb.AppendLine($"FreeSql Insert {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms");

			sw.Restart();
			for (var a = 0; a < forTime; a++) {
				using (var db = new FreeSongContext()) {
					db.Songs.AddRange(songs.ToArray());
					db.SaveChanges();
				}
			}
			sw.Stop();
			sb.AppendLine($"FreeSql.DbContext Insert {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms");

			sw.Restart();
			Exception sugarEx = null;
			try {
				for (var a = 0; a < forTime; a++)
					sugar.Insertable(songs.ToArray()).ExecuteCommand();
			} catch (Exception ex) {
				sugarEx = ex;
			}
			sw.Stop();
			sb.AppendLine($"SqlSugar Insert {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms" + (sugarEx != null ? $"成绩无效,错误:{sugarEx.Message}" : ""));

			sw.Restart();
			for (var a = 0; a < forTime; a++) {

				using (var db = new SongContext()) {
					//db.Configuration.AutoDetectChangesEnabled = false;
					db.Songs.AddRange(songs.ToArray());
					db.SaveChanges();
				}
			}
			sw.Stop();
			sb.AppendLine($"EFCore Insert {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms\r\n");
		}

19 View Source File : Program.cs
License : MIT License
Project Creator : 2881099

static void Select(StringBuilder sb, int forTime, int size) {
			Stopwatch sw = new Stopwatch();
			sw.Restart();
			for (var a = 0; a < forTime; a++)
				fsql.Select<Song>().Limit(size).ToList();
			sw.Stop();
			sb.AppendLine($"FreeSql Select {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms");

			sw.Restart();
			for (var a = 0; a < forTime; a++)
				sugar.Queryable<Song>().Take(size).ToList();
			sw.Stop();
			sb.AppendLine($"SqlSugar Select {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms");

			sw.Restart();
			for (var a = 0; a < forTime; a++) {
				using (var db = new SongContext()) {
					db.Songs.Take(size).AsNoTracking().ToList();
				}
			}
			sw.Stop();
			sb.AppendLine($"EFCore Select {size}条数据,循环{forTime}次,耗时{sw.ElapsedMilliseconds}ms\r\n");
		}

19 View Source File : SpeedtestHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private int GetTcpingTime(string url, int port)
        {
            int responseTime = -1;

            try
            {
                if (!IPAddress.TryParse(url, out IPAddress ipAddress))
                {
                    IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
                    ipAddress = ipHostInfo.AddressList[0];
                }

                Stopwatch timer = new Stopwatch();
                timer.Start();

                IPEndPoint endPoint = new IPEndPoint(ipAddress, port);
                Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

                IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
                if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5)))
                    throw new TimeoutException("connect timeout (5s): " + url);
                clientSocket.EndConnect(result);

                timer.Stop();
                responseTime = timer.Elapsed.Milliseconds;
                clientSocket.Close();
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
            return responseTime;
        }

19 View Source File : SpeedtestHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private string GetRealPingTime(string url, WebProxy webProxy, out int responseTime)
        {
            string msg = string.Empty;
            responseTime = -1;
            try
            {
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
                myHttpWebRequest.Timeout = 5000;
                myHttpWebRequest.Proxy = webProxy;//new WebProxy(Global.Loopback, Global.httpPort);

                Stopwatch timer = new Stopwatch();
                timer.Start();

                HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
                if (myHttpWebResponse.StatusCode != HttpStatusCode.OK
                    && myHttpWebResponse.StatusCode != HttpStatusCode.NoContent)
                {
                    msg = myHttpWebResponse.StatusDescription;
                }
                timer.Stop();
                responseTime = timer.Elapsed.Milliseconds;

                myHttpWebResponse.Close();
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
                msg = ex.Message;
            }
            return msg;
        }

19 View Source File : GCodeFile.cs
License : MIT License
Project Creator : 3RD-Dimension

public void GetModel(LinesVisual3D line, LinesVisual3D rapid, LinesVisual3D arc)
		{
			var sw = System.Diagnostics.Stopwatch.StartNew();

			Point3DCollection linePoints = new Point3DCollection();
			Point3DCollection rapidPoints = new Point3DCollection();
			Point3DCollection arcPoints = new Point3DCollection();

			foreach (Command c in Toolpath)
			{
				var l = c as Line;

				if (l != null)
				{
					if (l.Rapid)
					{
						rapidPoints.Add(l.Start.ToPoint3D());
						rapidPoints.Add(l.End.ToPoint3D());
					}
					else
					{
						linePoints.Add(l.Start.ToPoint3D());
						linePoints.Add(l.End.ToPoint3D());
					}

					continue;
				}

				var a = c as Arc;

				if (a != null)
				{
					foreach (Motion sub in a.Split(Settings.Default.ViewportArcSplit))
					{
						arcPoints.Add(sub.Start.ToPoint3D());
						arcPoints.Add(sub.End.ToPoint3D());
					}
				}
			}

			line.Points = linePoints;
			rapid.Points = rapidPoints;
			arc.Points = arcPoints;

			sw.Stop();
            MainWindow.Logger.Info("Generating the toolpath model took {0} ms", sw.ElapsedMilliseconds);
		}

19 View Source File : GCodeParser.cs
License : MIT License
Project Creator : 3RD-Dimension

public static void Parse(IEnumerable<string> file)
		{
			int i = 0;

			var sw = System.Diagnostics.Stopwatch.StartNew();

			foreach (string linei in file)
			{
				i++;
				string line = CleanupLine(linei, i);

				if (string.IsNullOrWhiteSpace(line))
					continue;

				Parse(line.ToUpper(), i);
			}

			sw.Stop();

            MainWindow.Logger.Info("parsing the G code file took {0} ms", sw.ElapsedMilliseconds);
		}

19 View Source File : JobAnimationCurveTests.cs
License : MIT License
Project Creator : 5argon

private (long mainTicks, long jobTicks) MainThreadPerformanceTest(AnimationCurve ac, int iterationCount)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            var jac = new JobAnimationCurve(ac, Allocator.Temp);

            float[] evaluated = new float[iterationCount];

            sw.Start();
            for (int i = 0; i < evaluated.Length; i++)
            {
                evaluated[i] = jac.Evaluate(i / (float)iterationCount);
            }
            sw.Stop();
            var jobTicks = sw.ElapsedTicks;

            sw.Reset();

            sw.Start();
            for (int i = 0; i < evaluated.Length; i++)
            {
                evaluated[i] = ac.Evaluate(i / (float)iterationCount);
            }
            sw.Stop();
            var mainTicks = sw.ElapsedTicks;


            jac.Dispose();

            return (mainTicks, jobTicks);
        }

19 View Source File : JobAnimationCurveTests.cs
License : MIT License
Project Creator : 5argon

private (long mainTicks, long jobTicks) TestEvaluate(AnimationCurve ac, int iterationCount)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            var jac = new JobAnimationCurve(ac, Allocator.TempJob);

            NativeArray<float> evaluated = new NativeArray<float>(iterationCount, Allocator.TempJob);
            NativeArray<float> jobEvaluated = new NativeArray<float>(iterationCount, Allocator.TempJob);
            var job = new CurveEvaluationJob
            {
                evaluated = jobEvaluated,
                jobAnimationCurve = jac
            }.Schedule(iterationCount, testEvaluateBatchCount, default(JobHandle));

            sw.Start();
            for (int i = 0; i < evaluated.Length; i++)
            {
                evaluated[i] = ac.Evaluate(i / (float)iterationCount);
            }
            sw.Stop();
            var mainTicks = sw.ElapsedTicks;
            sw.Reset();

            sw.Start();
            job.Complete();
            sw.Stop();
            var jobTicks = sw.ElapsedTicks;

            for (int i = 0; i < evaluated.Length; i++)
            {
                //Within 0.00001f, it is a bit inaccurate.
                replacedert.That(evaluated[i], Is.EqualTo(jobEvaluated[i]).Within(0.0001f),
                $"At index {i} (time {i / (float)iterationCount}) there is a difference of Unity {evaluated[i]} and Job {jobEvaluated[i]} ({evaluated[i] - jobEvaluated[i]})");
            }

            evaluated.Dispose();
            jobEvaluated.Dispose();
            jac.Dispose();

            return (mainTicks, jobTicks);
        }

19 View Source File : RequestMiddleware.cs
License : Apache License 2.0
Project Creator : 91270

public async Task InvokeAsync(HttpContext context)
        {
            // 过滤,只有接口
            if (context.Request.Path.Value.ToLower().Contains("api"))
            {
                context.Request.EnableBuffering();
                Stream originalBody = context.Response.Body;

                _stopwatch.Restart();

                // 获取 Api 请求内容
                var requestContent = await GetRequesContent(context);


                // 获取 Api 返回内容
                using (var ms = new MemoryStream())
                {
                    context.Response.Body = ms;

                    await _next(context);
                    ms.Position = 0;

                    await ms.CopyToAsync(originalBody);
                }

                context.Response.Body = originalBody;

                _stopwatch.Stop();

                var eventInfo = new LogEventInfo();
                eventInfo.Message = "Success";
                eventInfo.Properties["Elapsed"] = _stopwatch.ElapsedMilliseconds;
                eventInfo.Properties["RequestBody"] = requestContent;

                logger.Trace(eventInfo);
            }
            else
            {
                await _next(context);
            }
        }

19 View Source File : JobBase.cs
License : Apache License 2.0
Project Creator : 91270

public async Task<string> ExecuteJob(IJobExecutionContext context, Func<Task> job)
        {
            string jobHistory = $"Run Job [Id:{context.JobDetail.Key.Name},Group:{context.JobDetail.Key.Group}]";

            try
            {
                var s = context.Trigger.Key.Name;
                //记录Job时间
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                //执行任务
                await job();
                stopwatch.Stop();
                jobHistory += $", Succeed , Elapsed:{stopwatch.Elapsed.TotalMilliseconds} ms";
            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                //true  是立即重新执行任务 
                e2.RefireImmediately = true;
                jobHistory += $", Fail ,Exception:{ex.Message}";
            }

            return jobHistory;
        }

19 View Source File : UMAAssetIndexer.cs
License : Apache License 2.0
Project Creator : A7ocin

public T Getreplacedet<T>(int nameHash, string[] foldersToSearch = null) where T : UnityEngine.Object
        {
            System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
            st.Start();
            System.Type ot = typeof(T);
            Dictionary<string, replacedereplacedem> TypeDic = (Dictionary<string, replacedereplacedem>)TypeLookup[ot];
            string replacedetName = "";
            int replacedetHash = -1;
            foreach (KeyValuePair<string, replacedereplacedem> kp in TypeDic)
            {
                replacedetName = "";
                replacedetHash = -1;
                GetEvilreplacedetNameAndHash(typeof(T), kp.Value.Item, ref replacedetName, replacedetHash);
                if (replacedetHash == nameHash)
                {
                    if (replacedetFolderCheck(kp.Value, foldersToSearch))
                    {
                        st.Stop();
                        if (st.ElapsedMilliseconds > 2)
                        {
                            Debug.Log("Getreplacedet 0 for type "+typeof(T).Name+" completed in " + st.ElapsedMilliseconds + "ms");
                        }
                        return (kp.Value.Item as T);
                    }
                    else
                    {
                        st.Stop();
                        if (st.ElapsedMilliseconds > 2)
                        {
                            Debug.Log("Getreplacedet 1 for type " + typeof(T).Name + " completed in " + st.ElapsedMilliseconds + "ms");
                        }
                        return null;
                    }
                }
            }
            st.Stop();
            if (st.ElapsedMilliseconds > 2)
            {
                Debug.Log("Getreplacedet 2 for type " + typeof(T).Name + " completed in " + st.ElapsedMilliseconds + "ms");
            }
            return null;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectListTest(int count)
        {
            Stopwatch w = new Stopwatch();

            List<Employee> employeeList = new List<Employee>();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();

                Repository<Employee> repository = new Repository<Employee>(con);
                employeeList = repository.ReadAll().ToList();

                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long UpdateTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Update Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    Repository<Employee> repository = new Repository<Employee>(con);
                    repository.Update(emp);
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : UMAGeneratorBuiltin.cs
License : Apache License 2.0
Project Creator : A7ocin

public override void Work()
		{
			if (!IsIdle())
			{
				stopWatch.Reset();
				stopWatch.Start();
				OnDirtyUpdate();
				ElapsedTicks += stopWatch.ElapsedTicks;
#if UNITY_EDITOR
				UnityEditor.EditorUtility.SetDirty(this);
#endif
				stopWatch.Stop();
				UMATime.ReportTimeSpendtThisFrameTicks(stopWatch.ElapsedTicks);
			}
		}

19 View Source File : BitfinexSocketApi.cs
License : MIT License
Project Creator : aabiryukov

private BitfinexApiResult<long> WaitSubscription(BitfinexEventRegistration registration)
        {
            var sw = Stopwatch.StartNew();
            if (!registration.CompleteEvent.WaitOne(3000))
            {
                lock(eventListLock)
                    eventRegistrations.Remove(registration);
                return ThrowErrorMessage<long>(BitfinexErrors.GetError(BitfinexErrorKey.SubscriptionNotConfirmed));
            }
            sw.Stop();
            Log.Write(LogVerbosity.Info, $"Wait took {sw.ElapsedMilliseconds}ms");

            if (registration.Confirmed)
                return ReturnResult(registration.Id);

            lock(eventListLock)
                eventRegistrations.Remove(registration);
            return ThrowErrorMessage<long>(registration.Error);            
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long UpdateTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Update Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    con.Execute(@"UPDATE Employee SET EmployeeName = @EmployeeName,
                                            Location = @Location, Department = @Department,
                                            Designation = @Designation, DOB = @DOB, CTC = @CTC
                                        WHERE EmployeeId = @EmployeeId", emp);
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long InsertTest(int count)
        {
            PerformanceTest.TruncateTable();

            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling(( Convert.ToDecimal(i) / Convert.ToDecimal(count))*12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    SqlCommand cmd = con.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = @"INSERT INTO Employee (EmployeeId, EmployeeName, Location, Department, Designation, DOB, CTC)
                                        VALUES(@EmployeeId, @EmployeeName, @Location, @Department, @Designation, @DOB, @CTC)";

                    cmd.Parameters.AddWithValue("EmployeeId", emp.EmployeeId);
                    cmd.Parameters.AddWithValue("EmployeeName", emp.EmployeeName);
                    cmd.Parameters.AddWithValue("Location", emp.Location);
                    cmd.Parameters.AddWithValue("Department", emp.Department);
                    cmd.Parameters.AddWithValue("Designation", emp.Designation);
                    cmd.Parameters.AddWithValue("DOB", emp.DOB);
                    cmd.Parameters.AddWithValue("CTC", emp.CTC);

                    cmd.ExecuteNonQuery();
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectListTest(int count)
        {
            Stopwatch w = new Stopwatch();

            List<Employee> employeeList = new List<Employee>();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();

                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = [email protected]"SELECT TOP {count} EmployeeId, EmployeeName, Location, Department, Designation, DOB, CTC FROM Employee";
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    while(rdr.Read())
                    {
                        employeeList.Add(new Employee()
                        {
                            EmployeeId = rdr.GetInt32(0),
                            EmployeeName = rdr.GetString(1),
                            Location = rdr.GetString(2),
                            Department = rdr.GetString(3),
                            Designation = rdr.GetString(4),
                            DOB = rdr.GetDateTime(5),
                            CTC = rdr.GetDecimal(6)
                        });
                    }
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    SqlCommand cmd = con.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = @"SELECT EmployeeId, EmployeeName, Location, Department, Designation, DOB, CTC FROM Employee WHERE [email protected]";
                    cmd.Parameters.AddWithValue("EmployeeId", i);
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                        {
                            Employee emp = new Employee()
                            {
                                EmployeeId = rdr.GetInt32(0),
                                EmployeeName = rdr.GetString(1),
                                Location = rdr.GetString(2),
                                Department = rdr.GetString(3),
                                Designation = rdr.GetString(4),
                                DOB = rdr.GetDateTime(5),
                                CTC = rdr.GetDecimal(6)
                            };
                        }
                    }
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long InsertTest(int count)
        {
            PerformanceTest.TruncateTable();

            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    Repository<Employee> repository = new Repository<Employee>(con);
                    repository.Add(emp);
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Repository<Employee> repository = new Repository<Employee>(con);
                    repository.ReadOne(i);
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long UpdateTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Update Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    SqlCommand cmd = con.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = @"UPDATE Employee SET [email protected], 
                                            [email protected], [email protected], 
                                            [email protected], [email protected], [email protected]
                                        WHERE [email protected]";

                    cmd.Parameters.AddWithValue("EmployeeId", emp.EmployeeId);
                    cmd.Parameters.AddWithValue("EmployeeName", emp.EmployeeName);
                    cmd.Parameters.AddWithValue("Location", emp.Location);
                    cmd.Parameters.AddWithValue("Department", emp.Department);
                    cmd.Parameters.AddWithValue("Designation", emp.Designation);
                    cmd.Parameters.AddWithValue("DOB", emp.DOB);
                    cmd.Parameters.AddWithValue("CTC", emp.CTC);

                    cmd.ExecuteNonQuery();
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long InsertTest(int count)
        {
            PerformanceTest.TruncateTable();

            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    Employee emp = new Employee()
                    {
                        EmployeeId = i,
                        EmployeeName = "Employee " + i,
                        Location = "Location " + i,
                        Department = "Department " + i,
                        Designation = "Designation " + i,
                        DOB = new DateTime(1978, (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 12m), (int)Math.Ceiling((Convert.ToDecimal(i) / Convert.ToDecimal(count)) * 25m)),
                        CTC = i * 1000m
                    };

                    con.Execute(@"INSERT Employee(EmployeeId, EmployeeName, Location, Department, Designation, DOB, CTC)
                                        VALUES(@EmployeeId, @EmployeeName, @Location, @Department, @Designation, @DOB, @CTC)", emp);
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectListTest(int count)
        {
            Stopwatch w = new Stopwatch();

            List<Employee> employeeList = new List<Employee>();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();

                employeeList = con.Query<Employee>("SELECT * FROM Employee").ToList();

                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public long SelectTest(int count)
        {
            Stopwatch w = new Stopwatch();

            using (SqlConnection con = new SqlConnection(PerformanceTest.ConString))
            {
                con.Open();
                w.Start();
                for (int i = 1; i <= count; i++)
                {
                    con.QueryFirst<Employee>("SELECT * FROM Employee WHERE [email protected]", new { EmployeeId=i });
                }
                w.Stop();
                con.Close();
            }
            return w.ElapsedMilliseconds;
        }

19 View Source File : PerformanceTests.cs
License : MIT License
Project Creator : ababik

[TestMethod]
        public void SetFirstLevelProperyTest()
        {
            // ~12 ms

            var remute = new Remute();

            var stopwatch = new Stopwatch();
            stopwatch.Start();

            for (var i = 0; i < 1000; i++)
            {
                var organization = new Organization("organization 1", new Department("department 1", new Employee(Guid.NewGuid(), "developer", "manager"), null));
                var actual = remute.With(organization, x => x.Name, "organization 2");
            }

            stopwatch.Stop();

            var time = stopwatch.ElapsedMilliseconds;
            Console.WriteLine(time);
        }

19 View Source File : PerformanceTests.cs
License : MIT License
Project Creator : ababik

[TestMethod]
        public void SetNestedProperyTest()
        {
            // ~19 ms
            
            var remute = new Remute();

            var stopwatch = new Stopwatch();
            stopwatch.Start();

            for (var i = 0; i < 1000; i++)
            {
                var organization = new Organization("organization 1", new Department("department 1", new Employee(Guid.NewGuid(), "developer", "manager"), null));
                var actual = remute.With(organization, x => x.DevelopmentDepartment.Manager.FirstName, "name");
            }

            stopwatch.Stop();

            var time = stopwatch.ElapsedMilliseconds;
            Console.WriteLine(time);
        }

19 View Source File : IntegrationTests.cs
License : MIT License
Project Creator : Abc-Arbitrage

[Test]
        public void should_not_allocate()
        {
            const int count = 1000000;

            GC.Collect(2, GCCollectionMode.Forced, true);
            var timer = Stopwatch.StartNew();
            var gcCount = GC.CollectionCount(0);

            var logger = LogManager.GetLogger(typeof(IntegrationTests));
            for (var i = 0; i < count; i++)
            {
                Thread.Sleep(1);
                logger.Info().Append("Hello").Log();
            }

            LogManager.Shutdown();
            var gcCountAfter = GC.CollectionCount(0);
            timer.Stop();

            Console.WriteLine("BCL  : {0} us/log", timer.ElapsedMilliseconds * 1000.0 / count);
            Console.WriteLine("GCs  : {0}", gcCountAfter - gcCount);
        }

19 View Source File : PerformanceTests.cs
License : MIT License
Project Creator : Abc-Arbitrage

[Test]
        public void should_run_test()
        {
            const int threadMessageCount = 1000 * 1000;
            const int threadCount = 5;
            const int totalMessageCount = threadMessageCount * threadCount;

            var timer = Stopwatch.StartNew();

            var logger = LogManager.GetLogger(typeof(PerformanceTests));

            var signal = _testAppender.SetMessageCountTarget(totalMessageCount);
            var utcNow = DateTime.UtcNow;

            Parallel.For(0, threadCount, i =>
            {
                for (var k = 0; k < threadMessageCount; k++)
                {
                    logger.Info().Append("Hello ").Append(42).Append(utcNow).Append(42.56).Append(" this is a relatlively long message ").Append(12345.4332m).Log();
                }
            });

            var timedOut = !signal.Wait(TimeSpan.FromSeconds(10));

            timer.Stop();
            if (timedOut)
                replacedert.Fail("Timeout");

            Console.WriteLine($"Total message count  : {totalMessageCount:N0} messages");
            Console.WriteLine($"Thread message count : {threadMessageCount:N0} messages");
            Console.WriteLine($"Thread count         : {threadCount} threads");
            Console.WriteLine($"Elapsed time         : {timer.ElapsedMilliseconds:N0} ms");
            Console.WriteLine($"Message rate         : {totalMessageCount / timer.Elapsed.TotalSeconds:N0} m/s");
            Console.WriteLine($"Average log cost     : {timer.ElapsedMilliseconds * 1000 / (double)totalMessageCount:N3} µs");
        }

19 View Source File : SimRuntime.cs
License : MIT License
Project Creator : abdullin

public void Run(Func<SimControl, Task> plan) {
            _haltError = null;

            var watch = Stopwatch.StartNew();
            var reason = "none";
            
            Debug(LogType.RuntimeInfo,  $"{"start".ToUpper()}");
            Rand.Reinitialize(0);

            using (var cluster = new SimCluster(Def, this)) {
                
                Schedule(_scheduler,TimeSpan.Zero, _factory.StartNew(async () => {
                    var control = new SimControl(cluster, this);
                    try {
                        await plan(control);
                    } catch (Exception ex) {
                        Halt("Plan failed", ex);
                    }
                }));


                try {
                    var step = 0;
                    while (true) {
                        step++;

                        var hasFuture = FutureQueue.TryGetFuture(out var o);
                        if (!hasFuture) {
                            reason = "died";
                            break;
                        }

                        if (o.Time > _time) {
                            _time = o.Time;
                        }

                        switch (o.Item) {
                            case Task t:
                                o.Scheduler.Execute(t);
                                break;
                            default:
                                throw new InvalidOperationException();
                        }

                        if (_haltError != null || _haltMessage != null) {
                            reason = "halt";
                            break;
                        }

                        if ((_time - _lastActivity) >= _maxInactiveTicks) {
                            reason = "no activity " + Moment.Print(TimeSpan.FromTicks(_maxInactiveTicks));
                            break;
                        }

                        if (_steps >= MaxSteps) {
                            reason = MaxSteps + " steps reached";
                            break;
                        }

                        if (_time >= MaxTicks) {
                            reason = "max time";
                            break;
                        }
                    }
                } catch (Exception ex) {
                    reason = "fatal";
                    _haltError = ex;
                    Console.WriteLine("Fatal: " + ex);
                } finally {
                    if (_folder != null) {
                        Directory.Delete(_folder, true);
                    }
                }

                watch.Stop();

                var softTime = TimeSpan.FromTicks(_time);
                var factor = softTime.TotalHours / watch.Elapsed.TotalHours;

                if (_haltMessage != null) {
                    reason = _haltMessage.ToUpper();
                }

                Debug(LogType.RuntimeInfo,  $"{reason.ToUpper()} at {softTime}");

                if (_haltError != null) {
                    var demystify = _haltError.Demystify();
                    Console.WriteLine(demystify.GetType().Name + ": " + demystify.Message);
                    Console.WriteLine(demystify.StackTrace);
                }

                Console.WriteLine($"Simulated {Moment.Print(softTime)} in {_steps} steps.");
                Console.WriteLine($"Took {Moment.Print(watch.Elapsed)} of real time (x{factor:F0} speed-up)");
                // statistics
                
                Console.WriteLine($"Stats: {FutureQueue.JumpCount} jumps, {cluster.Machines.Sum(m => m.Value.SocketCount)} sockets");

            }

            

        }

See More Examples