Example #1
0
        private static int Run(Arguments args)
        {
            TestAssemblyScanner       scanner   = new TestAssemblyScanner();
            NUnitTestProjectProcessor processor = new NUnitTestProjectProcessor(scanner);

            string assembliesPath = args.AssembliesPath.FullName;

            Console.WriteLine("Loading assemblies from '{0}'", assembliesPath);

            var sw = new DebugStopwatch("1.Load NunitProject");

            string inputProjectPath = File.Exists(args.InputNUnitProject)
                                ? args.InputNUnitProject
                                : Path.Combine(assembliesPath, args.InputNUnitProject);

            if (!File.Exists(inputProjectPath))
            {
                Console.Error.WriteLine($"File Not Found: {args.InputNUnitProject}");
                return(-102);
            }

            NUnitTestProject inputProject = NUnitTestProject.LoadFromFile(inputProjectPath);

            sw.Dispose();

            int processedAssemblies = processor.Process(
                inputProject,
                args.SplitRules,
                assembliesPath,
                Path.GetDirectoryName(inputProjectPath)
                );

            Console.WriteLine("NUnitTestProjectSplitter finished. Processed {0} assemblies", processedAssemblies);
            return(0);
        }
        public void Test7Bit3()
        {
            byte[] data = new byte[4096 * 5];
            fixed (byte* lp = data)
            {
                using (var bs = new BinaryStreamPointerWrapper(lp, data.Length))
                {
                    DebugStopwatch sw = new DebugStopwatch();
                    var time = sw.TimeEventMedian(() =>
                    {
                        for (int repeat = 0; repeat < 1000; repeat++)
                        {
                            bs.Position = 0;
                            for (int x = 0; x < 1000; x++)
                            {
                                bs.Write7Bit(128u * 128u);
                                bs.Write7Bit(128u * 128u);
                                bs.Write7Bit(128u * 128u);
                                bs.Write7Bit(128u * 128u);
                            }
                        }

                    });
                    Console.WriteLine((4 * 1000 * 1000) / time / 1000 / 1000);
                }
            }
        }
        public void TestWriteLong()
        {
            byte[] data = new byte[4096 * 8];
            fixed(byte *lp = data)
            {
                using (var bs = new BinaryStreamPointerWrapper(lp, data.Length))
                {
                    DebugStopwatch sw   = new DebugStopwatch();
                    var            time = sw.TimeEventMedian(() =>
                    {
                        for (int repeat = 0; repeat < 1000; repeat++)
                        {
                            bs.Position = 0;
                            for (int x = 0; x < 1000; x++)
                            {
                                bs.Write((long)x);
                                bs.Write((long)x);
                                bs.Write((long)x);
                                bs.Write((long)x);
                            }
                        }
                    });

                    Console.WriteLine((4 * 1000 * 1000) / time / 1000 / 1000);
                }
            }
        }
        public void BenchmarkTwoFiles()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max = 1000000;
            ArchiveList <HistorianKey, HistorianValue> list = new ArchiveList <HistorianKey, HistorianValue>(null);
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();
            SortedTreeTable <HistorianKey, HistorianValue> table1 = CreateTable();
            SortedTreeTable <HistorianKey, HistorianValue> table2 = CreateTable();

            AddData(table1, 100, 100, Max / 2);
            AddData(table2, 101, 100, Max / 2);
            using (ArchiveListEditor <HistorianKey, HistorianValue> editor = list.AcquireEditLock())
            {
                editor.Add(table1);
                editor.Add(table2);
            }

            SequentialReaderStream <HistorianKey, HistorianValue> sequencer = new SequentialReaderStream <HistorianKey, HistorianValue>(list);

            DebugStopwatch sw = new DebugStopwatch();

            double sec = sw.TimeEvent(() =>
            {
                SequentialReaderStream <HistorianKey, HistorianValue> scanner = sequencer;
                while (scanner.Read(key, value))
                {
                }
            });

            System.Console.WriteLine(Max / sec / 1000000);
            list.Dispose();
            MemoryPoolTest.TestMemoryLeak();
        }
        public TestAssembly Scan(Assembly assembly)
        {
            var           sw = new DebugStopwatch("2.GetAssemblyCategories");
            List <string> assemblyCategories = assembly
                                               .GetCustomAttributes <CategoryAttribute>()
                                               .Select(attr => attr.Name)
                                               .ToList();

            sw.Dispose();

            sw = new DebugStopwatch("3.LoadTestFixturs");
            List <TestFixture> fixtures = assembly.GetTypes()
                                          .Select(LoadTestFixtureOrNull)
                                          .Where(f => f != null)
                                          .ToList();

            sw.Dispose();

            TestAssembly testAssembly = new TestAssembly(
                assembly,
                assemblyCategories,
                fixtures
                );

            foreach (var validator in m_validators)
            {
                using (new DebugStopwatch($"4.{validator.GetType().Name}")) {
                    validator.Validate(testAssembly);
                }
            }

            return(testAssembly);
        }
Example #6
0
 public void Test7Bit4()
 {
     byte[] data = new byte[4096 * 5];
     fixed(byte *lp = data)
     {
         using (BinaryStreamPointerWrapper bs = new BinaryStreamPointerWrapper(lp, data.Length))
         {
             DebugStopwatch sw   = new DebugStopwatch();
             double         time = sw.TimeEventMedian(() =>
             {
                 for (int repeat = 0; repeat < 1000; repeat++)
                 {
                     bs.Position = 0;
                     for (int x = 0; x < 1000; x++)
                     {
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                     }
                 }
             });
             Console.WriteLine(4 * 1000 * 1000 / time / 1000 / 1000);
         }
     }
 }
        public void BenchmarkRawFile()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max = 1000000;

            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            SortedTreeTable <HistorianKey, HistorianValue> master = CreateTable();

            AddData(master, 100, 100, Max);


            DebugStopwatch sw = new DebugStopwatch();

            using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> masterRead = master.BeginRead())
            {
                double sec = sw.TimeEvent(() =>
                {
                    SortedTreeScannerBase <HistorianKey, HistorianValue> scanner = masterRead.GetTreeScanner();
                    scanner.SeekToStart();
                    while (scanner.Read(key, value))
                    {
                    }
                });
                System.Console.WriteLine(Max / sec / 1000000);
            }
            master.Dispose();
            MemoryPoolTest.TestMemoryLeak();
        }
        public void TestBlocksPerSecond()
        {
            //UnmanagedMemory.Memory.UseLargePages = true;
            DebugStopwatch sw = new DebugStopwatch();

            using (MemoryPoolStream ms = new MemoryPoolStream())
            {
                using (BinaryStreamIoSessionBase io = ms.CreateIoSession())
                {
                    BlockArguments args = new BlockArguments();
                    args.Position  = ms.BlockSize * 2000L - 1;
                    args.IsWriting = true;

                    io.GetBlock(args);

                    double sec = sw.TimeEvent(() =>
                    {
                        for (int y = 0; y < 100; y++)
                        {
                            for (int x = 0; x < 2000; x++)
                            {
                                args.Position = (long)x * ms.BlockSize;
                                io.GetBlock(args);
                            }
                        }
                    });

                    System.Console.WriteLine("Get Blocks: " + (200000 / sec / 1000000).ToString("0.00 Million Per Second"));
                }
            }
        }
        public void RefreshSpeedTest()
        {
            ST.Reset();

            DebugStopwatch sw = new DebugStopwatch();
            double time = sw.TimeEvent(RefreshSpeed);
            Console.WriteLine(time.ToString() + " seconds to on average");

            Console.WriteLine(ST.GetResultsPercent());
        }
Example #10
0
        public void TestDHKeyExchangeTime()
        {
            var c = SrpConstants.Lookup(SrpStrength.Bits1024);

            c.g.ModPow(c.N, c.N);

            DebugStopwatch sw   = new DebugStopwatch();
            var            time = sw.TimeEvent(() => Hash <Sha1Digest> .Compute(c.Nb));

            System.Console.WriteLine(time);
        }
        public void RefreshSpeedTest()
        {
            ST.Reset();

            DebugStopwatch sw   = new DebugStopwatch();
            double         time = sw.TimeEvent(RefreshSpeed);

            Console.WriteLine(time.ToString() + " seconds to on average");

            Console.WriteLine(ST.GetResultsPercent());
        }
        public void BenchmarkRealisticSamples()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max       = 1000000;
            const int FileCount = 1000;
            ArchiveList <HistorianKey, HistorianValue> list = new ArchiveList <HistorianKey, HistorianValue>(null);
            DateTime       start = DateTime.Now.Date;
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            for (int x = 0; x < FileCount; x++)
            {
                SortedTreeTable <HistorianKey, HistorianValue> table1 = CreateTable();
                AddData(table1, start.AddMinutes(2 * x), new TimeSpan(TimeSpan.TicksPerSecond), 60, 100, 1, Max / 60 / FileCount);
                using (ArchiveListEditor <HistorianKey, HistorianValue> editor = list.AcquireEditLock())
                {
                    editor.Add(table1);
                }
            }

            SeekFilterBase <HistorianKey> filter = TimestampSeekFilter.CreateFromIntervalData <HistorianKey>(start, start.AddMinutes(2 * FileCount), new TimeSpan(TimeSpan.TicksPerSecond * 2), new TimeSpan(TimeSpan.TicksPerMillisecond));
            SequentialReaderStream <HistorianKey, HistorianValue> sequencer = new SequentialReaderStream <HistorianKey, HistorianValue>(list, null, filter);

            DebugStopwatch sw  = new DebugStopwatch();
            int            xi  = 0;
            double         sec = sw.TimeEvent(() =>
            {
                SequentialReaderStream <HistorianKey, HistorianValue> scanner = sequencer;
                while (scanner.Read(key, value))
                {
                    xi++;
                }
            });

            System.Console.WriteLine(Max / sec / 1000000);
            //TreeKeyMethodsBase<HistorianKey>.WriteToConsole();
            //TreeValueMethodsBase<HistorianValue>.WriteToConsole();

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
            list.Dispose();

            MemoryPoolTest.TestMemoryLeak();
        }
        public void Test1()
        {
            MemoryPoolTest.TestMemoryLeak();
            DebugStopwatch sw = new DebugStopwatch();

            for (int max = 10; max < 10000; max *= 2)
            {
                Action add1 = () =>
                {
                    SortedList <int, int> list = new SortedList <int, int>();
                    for (int x = 0; x < max; x++)
                    {
                        list.Add(x, x);
                    }
                };

                Action add2 = () =>
                {
                    List <int> keys   = new List <int>(max);
                    List <int> values = new List <int>(max);

                    for (int x = 0; x < max; x++)
                    {
                        keys.Add(x);
                        values.Add(x);
                    }

                    var sl = SortedListConstructor.Create(keys, values);
                };

                //var makeList = new SortedListConstructorUnsafe<int, int>();
                //Action add3 = () =>
                //{
                //    List<int> keys = new List<int>(max);
                //    List<int> values = new List<int>(max);

                //    for (int x = 0; x < max; x++)
                //    {
                //        keys.Add(x);
                //        values.Add(x);
                //    }

                //    var sl = makeList.Create(keys, values);
                //    //var sl = SortedListConstructor.CreateUnsafe(keys, values);

                //};
                System.Console.WriteLine("Old Method " + max + " " + sw.TimeEvent(add1) * 1000000);
                System.Console.WriteLine("New Method " + max + " " + sw.TimeEvent(add2) * 1000000);
                //Console.WriteLine("Unsafe Method " + max + " " + sw.TimeEvent(add3) * 1000000);
                MemoryPoolTest.TestMemoryLeak();
            }
        }
Example #14
0
        public IEnumerable <SplitRule> Scan(Assembly assembly, IList <SplitRule> splitRules)
        {
            ISet <SplitRule> appliedRules = new HashSet <SplitRule>();

            var           sw = new DebugStopwatch("3.GetAssemblyCategories");
            List <string> assemblyCategories = assembly
                                               .GetCustomAttributes(typeof(CategoryAttribute))
                                               .OfType <CategoryAttribute>()
                                               .Select(attr => attr.Name)
                                               .ToList();

            sw.Dispose();

            sw = new DebugStopwatch("4.LoadTestFixturs");
            List <TestFixture> fixtures = assembly.GetTypes()
                                          .Select(LoadTestFixtureOrNull)
                                          .Where(f => f != null)
                                          .ToList();

            sw.Dispose();

            using (new DebugStopwatch("5.SplitRules.Check")) {
                foreach (var fixture in fixtures)
                {
                    foreach (var method in fixture.TestMethods)
                    {
                        ISet <string> testCategories = method
                                                       .GetCustomAttributes <CategoryAttribute>(true)
                                                       .Select(attr => attr.Name)
                                                       .ToHashSet(StringComparer.OrdinalIgnoreCase);

                        testCategories.UnionWith(assemblyCategories);
                        testCategories.UnionWith(fixture.TestFixtureCategories);

                        foreach (var splitRule in splitRules)
                        {
                            if (!appliedRules.Contains(splitRule) &&
                                splitRule.RequiredCategories.All(c => testCategories.Contains(c)) &&
                                splitRule.ProhibitedCategories.All(c => !testCategories.Contains(c)))
                            {
                                appliedRules.Add(splitRule);
                            }
                        }
                    }
                }
            }

            return(appliedRules);
        }
        public int Process(
            NUnitTestProject inputProject,
            IList <SplitRule> rules,
            string assembliesPath,
            string outputPath
            )
        {
            AssemblyResolver.Setup(assembliesPath);
            int processedAssemblies = 0;

            IDictionary <string, NUnitTestProject> outputProjects = new SortedDictionary <string, NUnitTestProject>(
                rules.ToDictionary(rule => rule.TestProjectName, rule => new NUnitTestProject(inputProject.ActiveConfig))
                );

            foreach (var assemblyItem in inputProject.Assemblies)
            {
                string assemblyName = assemblyItem.Key;

                var      sw           = new DebugStopwatch("2.Load Assembly");
                string   assemblyPath = Path.Combine(assembliesPath, assemblyName);
                Assembly assembly     = AssemblyResolver.GetAssemblyOrNull(assemblyPath);
                sw.Dispose();

                if (assembly != null)
                {
                    IEnumerable <SplitRule> appliedRules = m_testAssemblyScanner.Scan(assembly, rules);

                    foreach (var rule in appliedRules)
                    {
                        outputProjects[rule.TestProjectName].Add(assemblyName, assemblyItem.Value);
                    }
                    processedAssemblies++;
                }
            }

            using (new DebugStopwatch("6.Save NunitProjects")) {
                foreach (var outputProject in outputProjects.Where(proj => proj.Value.Assemblies.Any()))
                {
                    string outputProjectPath = Path.Combine(outputPath, outputProject.Key);
                    outputProject.Value.Save(outputProjectPath);
                }
            }

            using (IndentedTextWriter writer = new IndentedTextWriter(Console.Error, "\t")) {
                DebugStopwatch.Report(writer);
            }

            return(processedAssemblies);
        }
        public void TestImmediateJob()
        {
            // Pass debug stopwatch so time doesn't advance.
            var sw    = new DebugStopwatch();
            var queue = new JobQueue(sw);

            var job = new ImmediateJob();

            queue.EnqueueJob(job);

            queue.Process();

            Assert.That(job.Status, Is.EqualTo(JobStatus.Finished));
            Assert.That(job.Result, Is.EqualTo("honk!"));
        }
Example #17
0
        public void Test()
        {
            Console.WriteLine(Environment.StackTrace);

            RunMethod();
            DebugStopwatch sw   = new DebugStopwatch();
            double         time = sw.TimeEvent(() =>
            {
                for (int x = 0; x < 1000; x++)
                {
                    RunMethod3();
                }
            });

            Console.WriteLine(1000 / time);
        }
Example #18
0
        public void TestReadData()
        {
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            var settings = new HistorianServerDatabaseConfig("PPA", @"c:\temp\Scada\", true);

            using (HistorianServer server = new HistorianServer(settings))
            {
                double count = 0;

                DebugStopwatch sw   = new DebugStopwatch();
                double         time = sw.TimeEvent(() =>
                {
                    count = 0;
                    using (HistorianClient client = new HistorianClient("127.0.0.1", 12345))
                        using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty))
                        {
                            //IHistorianDatabase<HistorianKey, HistorianValue> database = server.GetDefaultDatabase();//.GetDatabase();
                            //TreeStream<HistorianKey, HistorianValue> stream = reader.Read(0, ulong.MaxValue, new ulong[] { 2 });
                            TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, ulong.MaxValue);
                            while (stream.Read(key, value))
                            {
                                count++;
                            }
                        }
                });

                Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");
            }

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
            //for (int x = 0; x < 15; x++)
            //{
            //    Console.WriteLine(BinaryStreamBase.CallMethods[x] + "\t" + ((BinaryStreamBase.Method)(x)).ToString());
            //}
        }
Example #19
0
        public void BenchmarkWriteSpeed()
        {
            DebugStopwatch sw = new DebugStopwatch();

            double time;
            double count = 0;

            using (SortedTreeFile file = SortedTreeFile.CreateInMemory())
            {
                var            table = file.OpenOrCreateTable <HistorianKey, HistorianValue>(HistorianFileEncodingDefinition.TypeGuid);
                HistorianKey   key   = new HistorianKey();
                HistorianValue value = new HistorianValue();

                time = sw.TimeEvent(() =>
                {
                    //TreeKeyMethodsBase<HistorianKey>.ClearStats();
                    //TreeValueMethodsBase<HistorianKey>.ClearStats();
                    count = 0;
                    using (var scan = table.BeginEdit())
                    {
                        for (uint x = 0; x < 10000000; x++)
                        {
                            key.PointID = x;
                            scan.AddPoint(key, value);
                            count++;
                        }
                        scan.Rollback();
                    }
                });
            }

            Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
        }
Example #20
0
        public void TestReadDataFromArchive()
        {
            DebugStopwatch sw    = new DebugStopwatch();
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            string path = Directory.GetFiles(@"c:\temp\Scada\", "*.d2")[0];
            double time;
            double count = 0;

            using (SortedTreeFile file = SortedTreeFile.OpenFile(path, true))
            {
                var table = file.OpenTable <HistorianKey, HistorianValue>();

                time = sw.TimeEvent(() =>
                {
                    count = 0;
                    using (var scan = table.BeginRead())
                    {
                        var t = scan.GetTreeScanner();
                        t.SeekToStart();
                        while (t.Read(key, value))
                        {
                            count++;
                        }
                    }
                });
            }
            Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
        }
        public void TestWaitingJob()
        {
            var sw    = new DebugStopwatch();
            var queue = new LongJobQueue(sw);

            var tcs = new TaskCompletionSource <object>();

            var job = new WaitingJob(tcs.Task);

            queue.EnqueueJob(job);

            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Waiting));
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Waiting));
            tcs.SetResult(1);
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Finished));

            Assert.That(job.Result, Is.EqualTo("oof!"));
        }
        public void TestLongJob()
        {
            var swA   = new DebugStopwatch();
            var swB   = new DebugStopwatch();
            var queue = new LongJobQueue(swB);

            var job = new LongJob(swA, swB);

            queue.EnqueueJob(job);

            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Paused));
            Assert.That((float)job.DebugTime, new ApproxEqualityConstraint(1f));
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Paused));
            Assert.That((float)job.DebugTime, new ApproxEqualityConstraint(2f));
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Finished));

            Assert.That(job.Result, Is.EqualTo("foo!"));
            Assert.That((float)job.DebugTime, new ApproxEqualityConstraint(2.4f));
        }
        public void TestLongJobCancel()
        {
            var swA   = new DebugStopwatch();
            var swB   = new DebugStopwatch();
            var queue = new LongJobQueue(swB);

            var cts = new CancellationTokenSource();
            var job = new LongJob(swA, swB, cts.Token);

            queue.EnqueueJob(job);

            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Paused));
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Paused));
            cts.Cancel();
            queue.Process();
            Assert.That(job.Status, Is.EqualTo(JobStatus.Finished));
            Assert.That((float)job.DebugTime, new ApproxEqualityConstraint(2.0f));

            Assert.That(job.Result, Is.Null);
        }
        private static int Run(Arguments args)
        {
            string path = args.AssembliesPath.FullName;

            SetupAssemblyResolver(path);

            Console.WriteLine("Loading assemblies from '{0}'", path);

            var sw = new DebugStopwatch("1.LoadAssemblies");
            IEnumerable <Assembly> assemblies = args.AssembliesPath
                                                .EnumerateFiles("*.dll", SearchOption.TopDirectoryOnly)
                                                .Where(file => !args.ExcludedAssemblies.Contains(file.Name))
                                                .Select(GetAssemblyOrNull)
                                                .Where(ass => ass != null)
                                                .Where(NUnitFrameworkReferenceChecker.ReferencesNUnitFramework);

            sw.Dispose();

            int violations = 0;

            TestAssemblyScanner scanner = new TestAssemblyScanner(
                new IAssemblyValidator[] {
                new ProhibitedAssemblyCategoryValidator(args.ProhibitedAssemblyCategories),
                new RequaredCategoryValidator(args.RequiredCategories)
            });

            using (IndentedTextWriter writer = new IndentedTextWriter(Console.Error, "\t")) {
                foreach (Assembly assembly in assemblies)
                {
                    TestAssembly testAssembly = scanner.Scan(assembly);
                    violations += Report(testAssembly, writer);
                }

                DebugStopwatch.Report(writer);
            }

            return(violations);
        }
 public LongJob(DebugStopwatch stopwatchA, DebugStopwatch stopwatchB, CancellationToken cancel = default) :
     base(0.95, stopwatchA, cancel)
 {
     _stopwatch  = stopwatchA;
     _stopwatchB = stopwatchB;
 }
Example #26
0
    protected IEnumerator doTasksCo()
    {
        parallel = Parallel;
        DebugStopwatch.Reset();
        //如果有条件的话判断条件,如果条件直接不匹配的话,直接短路这个Task,并且移出处理列表
        for (int i = 0; i < waitingTasks.Count; ++i)
        {
            var task = waitingTasks[i];
            if (task.condition != null)
            {
                if (!task.condition())
                {
                    task.isDone = true;
                }
            }
        }
        waitingTasks.RemoveAll(t => t.isDone);

        //统计全部Task的权重
        for (int i = 0; i < waitingTasks.Count; ++i)
        {
            totalProgress += waitingTasks[i].weight;
        }

        while (processingTasks.Count > 0 || waitingTasks.Count > 0)
        {
            bool  hasFinishedTask  = false;
            float paratialProgress = 0;
            for (int i = processingTasks.Count - 1; i >= 0; --i)
            {
                var task = processingTasks[i];
                if (task.isDone)
                {
                    finishedProgress += task.weight;
                    processingTasks.RemoveAt(i);
                    hasFinishedTask = true;

                    if (!parallel)
                    {
                        DebugStopwatch.Lap(task.name ?? "");
                    }
                }
                else
                {
                    var p = task.calcProgress == null
                        ? Mathf.Clamp01((Time.time - task._taskStartTime) / task.weight)
                        : task.calcProgress() * task.weight;

                    paratialProgress += p;
                }
            }
            paratialProgress = (finishedProgress + paratialProgress) / totalProgress;
            if (parallel)
            {
                if (hasFinishedTask || processingTasks.Count == 0)
                {
                    for (int i = waitingTasks.Count - 1; i >= 0; --i)
                    {
                        tryDequeueOneWaitingTask(i);
                    }
                }
            }
            else
            {
                if (processingTasks.Count == 0)
                {
                    for (int i = 0; i < waitingTasks.Count; i++)
                    {
                        if (tryDequeueOneWaitingTask(i))
                        {
                            break;
                        }
                    }
                }
            }
            yield return(null);
        }
        DebugStopwatch.Lap(this.GetType().Name + "Finish");
    }