Пример #1
0
        public NotificationPageViewModel()
        {
            _realmBenchmark             = new RealmBenchmark();
            LoadRealmPublicationCommand = new Command(async() =>
            {
                CurrentPublicationRealm = await _realmBenchmark.GetPublication(_remoteId);
                _remoteId++;
            });

            DownloadRealmPublicationCommand = new Command(async() => await DownloadRealmPublication());
            _downloadService = new DownloadService();
        }
Пример #2
0
        public async Task <List <TimeSpan> > RunTest(TestSpec spec)
        {
            var benchmark = new RealmBenchmark();
            Action <BenchmarkBase> testAction      = null;
            Action <BenchmarkBase> prepareDbAction = null;

            switch (spec.TestCase)
            {
            case BenchmarkTest.Insert:
                testAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.Count:
                testAction      = CountPublications;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.Select:
                testAction      = EnumeratePublications;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.UpdateManyTransactions:
                testAction      = UpdatePublicationsInManyTransactions;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.UpdateSingleTransaction:
                testAction      = UpdatePublicationsInSingleTransaction;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.DeleteManyTransaction:
                testAction      = DeletePublicationsInManyTransactions;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.DeleteSingleTransaction:
                testAction      = DeletePublicationsInSingleTransaction;
                prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.ManyToManyInsert:
                testAction = b => InsertPublicationsAndCollections(b, spec.NumberOfItems);
                //prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;

            case BenchmarkTest.SelectCollections:
                prepareDbAction = b => InsertPublicationsAndCollections(b, spec.NumberOfItems);
                testAction      = SelectCollections;
                //prepareDbAction = b => InsertPublications(b, spec.NumberOfItems);
                break;
            }

            benchmark.DeleteDB();

            var results = new List <TimeSpan>();

            for (int i = 0; i < spec.RepeatTimes; i++)
            {
                await Task.Run(() =>
                {
                    using (benchmark.OpenDB())
                    {
                        prepareDbAction?.Invoke(benchmark);

                        results.Add(benchmark.PerformTest(testAction));
                    }
                });

                if (spec.RemoveDbBetweenIterations)
                {
                    benchmark.DeleteDB();
                }
            }

            return(results);
        }