public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsInterception)
            {
                BenchmarkBase.CollectMemory();

                var watch = new Stopwatch();

                watch.Start();

                for (int i = 0; i < BenchmarkBase.LoopCount; i++)
                {
                    var result1 = (ICalculator1)container.ResolveProxy(typeof(ICalculator1));
                    var result2 = (ICalculator2)container.ResolveProxy(typeof(ICalculator2));
                    var result3 = (ICalculator3)container.ResolveProxy(typeof(ICalculator3));

                    result1.Add(5, 10);
                    result2.Add(5, 10);
                    result3.Add(5, 10);
                }

                watch.Stop();

                result.Time = watch.ElapsedMilliseconds;
            }

            return(result);
        }
예제 #2
0
        public override void InsertObject(uint index)
        {
            var employee = this.realm.CreateObject <Employee>();

            employee.Name    = BenchmarkBase.NameValue(index);
            employee.Age     = Benchmark.AgeValue(index);
            employee.IsHired = Benchmark.IsHiredValue(index);
        }
예제 #3
0
 public override void InsertObject(uint index)
 {
     this.realm.Add(new Employee
     {
         Name    = BenchmarkBase.NameValue(index),
         Age     = Benchmark.AgeValue(index),
         IsHired = Benchmark.IsHiredValue(index)
     });
 }
예제 #4
0
 public override void InsertObject(uint index)
 {
     this.db.CreateDocument()
     .PutProperties(new Dictionary <string, object>
     {
         ["name"]     = BenchmarkBase.NameValue(index),
         ["age"]      = BenchmarkBase.AgeValue(index),
         ["is_hired"] = BenchmarkBase.IsHiredValue(index)
     });
 }
예제 #5
0
 private static void InsertPublications(BenchmarkBase benchmark, int numberOfPublications = 5000)
 {
     benchmark.RunInTransaction(() =>
     {
         for (int i = 0; i < numberOfPublications; i++)
         {
             benchmark.InsertPublication(i);
         }
     });
 }
예제 #6
0
        public override void InsertObject(uint index)
        {
            var employee = new Employee
            {
                Name    = BenchmarkBase.NameValue(index),
                Age     = BenchmarkBase.AgeValue(index),
                IsHired = BenchmarkBase.IsHiredValue(index)
            };

            this.connection.Insert(employee);
        }
예제 #7
0
        /** <inheritdoc/> */
        public void Initialize(BenchmarkBase benchmark, ICollection <string> opNames)
        {
            _benchmarks = new Dictionary <string, BenchmarkTask>(opNames.Count);

            // 1. Create folder for results.
            var now = DateTime.Now;

            var suffix = "-t=" + benchmark.Threads + "-d=" + benchmark.Duration +
                         "-w=" + benchmark.Warmup;

            var path = benchmark.ResultFolder + "\\" + now.ToString("yyyyMMdd-HHmmss", Culture) + "-" +
                       benchmark.GetType().Name + suffix;

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            Directory.CreateDirectory(path);

            var dateStr = "--Created " + DateTime.Now.ToString("yyyyMMdd-HHmmss", Culture);
            var cfgStr  = "--Benchmark config: " + benchmark;

            // 2. For each operation create separate folder and initialize probe files there.
            foreach (var opName in opNames)
            {
                var opDesc = benchmark.GetType().Name + "-" + opName + suffix;
                var opPath = path + "\\" + opDesc;

                Directory.CreateDirectory(opPath);

                var task = new BenchmarkTask(opPath + "\\" + ProbePercentile,
                                             opPath + "\\" + ProbeThroughput);

                _benchmarks[opName] = task;

                File.AppendAllText(task.FilePercentile, dateStr + "\n");
                File.AppendAllText(task.FilePercentile, cfgStr + "\n");
                File.AppendAllText(task.FilePercentile, "--Description: " + opDesc + "\n");
                File.AppendAllText(task.FilePercentile, "@@" + benchmark.GetType().Name + "\n");
                File.AppendAllText(task.FilePercentile, HdrPercentile + "\n");

                File.AppendAllText(task.FileThroughput, dateStr + "\n");
                File.AppendAllText(task.FileThroughput, cfgStr + "\n");
                File.AppendAllText(task.FileThroughput, "--Description: " + opDesc + "\n");
                File.AppendAllText(task.FileThroughput, "@@" + benchmark.GetType().Name + "\n");
                File.AppendAllText(task.FileThroughput, HdrThroughput + "\n");
            }

            // 3. Start writer thread.
            new Thread(_writer.Run).Start();
        }
        /** <inheritdoc/> */
        public void Initialize(BenchmarkBase benchmark, ICollection<string> opNames)
        {
            _benchmarks = new Dictionary<string, BenchmarkTask>(opNames.Count);

            // 1. Create folder for results.
            var now = DateTime.Now;

            var suffix = "-t=" + benchmark.Threads + "-d=" + benchmark.Duration +
                         "-w=" + benchmark.Warmup;

            var path = benchmark.ResultFolder + "\\" + now.ToString("yyyyMMdd-HHmmss", Culture) + "-" +
                       benchmark.GetType().Name + suffix;

            if (Directory.Exists(path))
                Directory.Delete(path, true);

            Directory.CreateDirectory(path);

            var dateStr = "--Created " + DateTime.Now.ToString("yyyyMMdd-HHmmss", Culture);
            var cfgStr = "--Benchmark config: " + benchmark;

            // 2. For each operation create separate folder and initialize probe files there.
            foreach (var opName in opNames)
            {
                var opDesc = benchmark.GetType().Name + "-" + opName + suffix;
                var opPath = path + "\\" + opDesc;

                Directory.CreateDirectory(opPath);

                var task = new BenchmarkTask(opPath + "\\" + ProbePercentile,
                    opPath + "\\" + ProbeThroughput);

                _benchmarks[opName] = task;

                File.AppendAllText(task.FilePercentile, dateStr + "\n");
                File.AppendAllText(task.FilePercentile, cfgStr + "\n");
                File.AppendAllText(task.FilePercentile, "--Description: " + opDesc + "\n");
                File.AppendAllText(task.FilePercentile, "@@" + benchmark.GetType().Name + "\n");
                File.AppendAllText(task.FilePercentile, HdrPercentile + "\n");

                File.AppendAllText(task.FileThroughput, dateStr + "\n");
                File.AppendAllText(task.FileThroughput, cfgStr + "\n");
                File.AppendAllText(task.FileThroughput, "--Description: " + opDesc + "\n");
                File.AppendAllText(task.FileThroughput, "@@" + benchmark.GetType().Name + "\n");
                File.AppendAllText(task.FileThroughput, HdrThroughput + "\n");
            }

            // 3. Start writer thread.
            new Thread(_writer.Run).Start();
        }
예제 #9
0
        private void InsertPublicationsAndCollections(BenchmarkBase benchmark, int numberOfItems)
        {
            InsertPublications(benchmark, numberOfItems);
            var numberOfCollection = numberOfItems / 50;
            var itemsInCollection  = numberOfCollection / 2;

            for (int i = 0; i < numberOfCollection; i++)
            {
                var index = i;
                benchmark.RunInTransaction(() =>
                {
                    benchmark.InsertCollection(index, itemsInCollection, numberOfItems);
                });
            }
        }
예제 #10
0
        private void EnumeratePublications(BenchmarkBase benchmark)
        {
            var total = benchmark.EnumeratePublications();

            Debug.WriteLine($"Counting enumerate publications: {total}");
        }
 /** <inheritdoc/> */
 public void Initialize(BenchmarkBase benchmark, ICollection <string> opNames)
 {
     _benchmark = benchmark;
 }
 /** <inheritdoc/> */
 public void Initialize(BenchmarkBase benchmark, ICollection<string> opNames)
 {
     _benchmark = benchmark;
 }
예제 #13
0
 public BenchmarkResult(BenchmarkBase benchmark, IContainerAdapter container)
 {
     this.Benchmark = benchmark;
     this.Container = container;
 }
예제 #14
0
 private void SelectCollections(BenchmarkBase benchmark)
 {
     benchmark.SelectCollections();
 }
예제 #15
0
        private static void CountPublications(BenchmarkBase benchmark)
        {
            var count = benchmark.PublicationCount();

            Debug.WriteLine($"Counting publications: {count}");
        }
예제 #16
0
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsChildContainer)
            {
                BenchmarkBase.CollectMemory();

                var watch = new Stopwatch();

                watch.Start();

                for (int i = 1; i <= BenchmarkBase.LoopCount; i++)
                {
                    using (var childContainer = container.CreateChildContainerAdapter())
                    {
                        childContainer.Prepare();

                        var scopedCombined = (ICombined1)childContainer.Resolve(typeof(ICombined1));
                    }

                    using (var childContainer = container.CreateChildContainerAdapter())
                    {
                        childContainer.Prepare();

                        var scopedCombined = (ICombined2)childContainer.Resolve(typeof(ICombined2));
                    }

                    using (var childContainer = container.CreateChildContainerAdapter())
                    {
                        childContainer.Prepare();

                        var scopedCombined = (ICombined3)childContainer.Resolve(typeof(ICombined3));
                    }

                    // If measurement takes more than three minutes, stop and interpolate result
                    if (i % 500 == 0 && watch.ElapsedMilliseconds > 3 * 60 * 1000)
                    {
                        watch.Stop();

                        ScopedCombined1.Instances = BenchmarkBase.LoopCount;
                        ScopedCombined2.Instances = BenchmarkBase.LoopCount;
                        ScopedCombined3.Instances = BenchmarkBase.LoopCount;

                        long interpolatedResult = watch.ElapsedMilliseconds * BenchmarkBase.LoopCount / i;

                        Console.WriteLine(
                            " Child container benchmark for '{0}' was stopped after {1:f1} minutes. {2} of {3} instances have been resolved. Total execution would haven taken: {4:f1} minutes",
                            container.Name,
                            (double)watch.ElapsedMilliseconds / (1000 * 60),
                            i,
                            BenchmarkBase.LoopCount,
                            (double)interpolatedResult / (1000 * 60));
                        result.Time = interpolatedResult;

                        return(result);
                    }
                }

                watch.Stop();

                result.Time = watch.ElapsedMilliseconds;
            }

            return(result);
        }
예제 #17
0
        private void UpdatePublicationsInManyTransactions(BenchmarkBase benchmark)
        {
            var total = benchmark.UpdatePublicationsInManyTransactions();

            Debug.WriteLine($"Total publications updated: {total}");
        }
예제 #18
0
 private void DeletePublicationsInSingleTransaction(BenchmarkBase benchmark)
 {
     benchmark.DeletePublicationsInSingleTransaction();
     Debug.WriteLine($"All publications have been removed");
 }