Beispiel #1
0
        public void ExecuteStrategy(IDbConnector db, ModelDataType dataType)
        {
            var mf        = new ModelFactory();
            var stopwatch = new Stopwatch();

            Delays = new List <long>();
            var tmp = new List <long>();

            for (var i = 0; i < CountOfOperations; i++)
            {
                stopwatch.Start();

                var data = mf.GetDemoModel(dataType);
                try
                {
                    db.Insert(data);
                    db.Read <BaseModel>(data.Id);
                }
                catch (Exception e)
                {
                    Console.WriteLine("ERROR");
                }
                stopwatch.Stop();
                tmp.Add((stopwatch.ElapsedMilliseconds * 1000));
                stopwatch.Reset();
                if (tmp.Count == 100)
                {
                    Delays.Add((long)tmp.Average(x => x));
                    tmp = new List <long>();
                }
            }
        }
Beispiel #2
0
        public void ExecuteStrategy(IDbConnector db, ModelDataType dataType)
        {
            var rand            = new Random();
            var readEveryNWrite = (int)(CountOfOperations / (int)(ReadsToWritesRatio * CountOfOperations));
            var mf        = new ModelFactory();
            var stopwatch = new Stopwatch();

            Delays = new List <long>();
            var tmp           = new List <long>();
            var max           = ModelFactory.Max - 4;
            var minInsertedId = ModelFactory._iterator + 1;

            for (var i = 0; i < CountOfOperations; i++)
            {
                stopwatch.Start();


                db.Read <BaseModel>(rand.Next(minInsertedId, max));
                if (i % (readEveryNWrite) == 0)
                {
                    var data = mf.GetDemoModel(dataType);
                    db.Insert(data);
                }

                stopwatch.Stop();
                tmp.Add((stopwatch.ElapsedMilliseconds * 1000));
                stopwatch.Reset();
                if (tmp.Count == 100)
                {
                    Delays.Add((long)tmp.Average(x => x));
                    tmp = new List <long>();
                }
            }
        }
Beispiel #3
0
        public void ExecuteStrategy(IDbConnector db, ModelDataType dataType)
        {
            var mf        = new ModelFactory();
            var stopwatch = new Stopwatch();

            Delays = new List <long>();
            var tmp = new List <long>();

            for (var i = 0; i < CountOfOperations; i++)
            {
                stopwatch.Start();

                var data = mf.GetDemoModel(dataType);

                db.Update(data.Id, data);


                stopwatch.Stop();
                tmp.Add((stopwatch.ElapsedMilliseconds * 1000));
                stopwatch.Reset();
                if (tmp.Count == 100)
                {
                    Delays.Add((long)tmp.Average(x => x));
                    tmp = new List <long>();
                }
            }
        }
Beispiel #4
0
        public void ExecuteStrategy(IDbConnector db, ModelDataType dataType)
        {
            var stopwatch = new Stopwatch();

            Delays = new List <long>();
            var rand = new Random();
            var max  = ModelFactory.Max;
            var tmp  = new List <long>();

            for (var i = 0; i < CountOfOperations; i++)
            {
                stopwatch.Start();

                var id = rand.Next(max - CountOfOperations + 1, max - 10);
                db.Read <BaseModel>(id);

                stopwatch.Stop();
                tmp.Add((stopwatch.ElapsedMilliseconds * 1000));
                stopwatch.Reset();
                if (tmp.Count == 100)
                {
                    Delays.Add((long)tmp.Average(x => x));
                    tmp = new List <long>();
                }
            }
        }
        public IBenchmark GetBenchmark(BenchmarkType benchmarkType, ModelDataType modelType)
        {
            switch (benchmarkType)
            {
            case BenchmarkType.Memcached:
                return(new MemcachedBenchmark());

            case BenchmarkType.MongoDB:
                return(GetMongoBenchmark(modelType));

            case BenchmarkType.Redis:
                return(GetRedisBenchmark(modelType));

            case BenchmarkType.Couchbase:
                return(new CouchbaaseBenchmark());

            case BenchmarkType.OrientDb:
                return(new OrientDbBenchmark());

            case BenchmarkType.Riak:
                return(new RiakBenchmark());

            default:
                throw new ArgumentOutOfRangeException(nameof(benchmarkType), benchmarkType, null);
            }
        }
        private static IBenchmark GetDynamoBenchmark(ModelDataType modelType)
        {
            switch (modelType)
            {
            case ModelDataType.Reddit:
                return(new DymanoDbBenchmark <RedditModel>());

            case ModelDataType.Tweeter:
                return(new DymanoDbBenchmark <YoutubeModel>());

            default:
                throw new ArgumentOutOfRangeException(nameof(modelType), modelType, null);
            }
        }
        public IList <IBenchmark> GetAllBenchmarks(ModelDataType modelType)
        {
            var benchmarks = new List <IBenchmark>
            {
                GetMongoBenchmark(modelType),
                new MemcachedBenchmark(),
                GetRedisBenchmark(modelType),
                new CouchbaaseBenchmark(),
                new RiakBenchmark(),
                new OrientDbBenchmark()
            };

            //benchmarks.Add(new RavenDbBenchmark());
            return(benchmarks);
        }
        public BaseModel GetDemoModel(ModelDataType dataType)
        {
            switch (dataType)
            {
            case ModelDataType.Reddit:
                return(_news[--_iterator]);

            case ModelDataType.Tweeter:
                return(_tweeter[--_iterator]);

            case ModelDataType.Youtube:
                return(_youtube[--_iterator]);

            default:
                throw new ArgumentOutOfRangeException(nameof(dataType), dataType, null);
            }
        }
Beispiel #9
0
        private Model3DGroup LoadModel(Stream model, ModelDataType type,
                                       string textureFilePath = null, bool freeze = false)
        {
            ModelReader reader = null;

            switch (type)
            {
            case ModelDataType.OBJ: reader = new ObjReader(); break;

            case ModelDataType.STL: reader = new StLReader(); break;

            case ModelDataType.ThreeDS: reader = new StudioReader(); break;
            }
            if (reader == null)
            {
                throw new NotSupportedException("Given model type is not supported");
            }
            reader.TexturePath = textureFilePath != null ? textureFilePath : "";
            reader.Freeze      = freeze;
            //using (model)
            return(reader.Read(model));
        }
Beispiel #10
0
        private async void PrepareModel(Stream model, ModelDataType type,
                                        string texturePath = null, bool async = false)//, bool freezeModel = false)
        {
            // ui
            m_viewModel.ApplicationStatus = "Loading model file";
            //c_contourToggle.IsChecked = false;

            // loading
            Dispatcher   modelDispatcher;
            Model3DGroup modelContent;

            if (async)
            {
                var modelAndDispatcher = await LoadModelAsync(model, type, texturePath, false);

                modelContent    = modelAndDispatcher.Item1;
                modelDispatcher = modelAndDispatcher.Item2;
            }
            else
            {
                modelContent    = LoadModel(model, type, texturePath, false);
                modelDispatcher = this.Dispatcher;
            }

            // setting materials
            modelDispatcher.Invoke(() =>
            {
                foreach (var m in modelContent.Children)
                {
                    //(m as GeometryModel3D).BackMaterial = null;
                    (m as GeometryModel3D).Material     = m_replacementMaterial;
                    (m as GeometryModel3D).BackMaterial = m_replacementMaterial;// m_replacementMaterial;
                    m.Freeze();
                }
            });
            m_currentModel = modelContent;
        }
 private void ModelCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     selectedModel = (ModelDataType)ModelCmb.SelectedItem;
 }
Beispiel #12
0
 private async Task <Tuple <Model3DGroup, Dispatcher> > LoadModelAsync(string filePath, ModelDataType type,
                                                                       string textureFilePath = null, bool freeze = false)
 {
     return(await LoadModelAsync(File.OpenRead(filePath), type, textureFilePath, freeze));
 }
Beispiel #13
0
 private async Task <Tuple <Model3DGroup, Dispatcher> > LoadModelAsync(Stream model, ModelDataType type,
                                                                       string textureFilePath = null, bool freeze = false)
 {
     return(await Task.Run(() => Tuple.Create(LoadModel(model, type, textureFilePath, freeze), this.Dispatcher)).ConfigureAwait(true));
 }
Beispiel #14
0
 private Model3DGroup LoadModel(string filePath, ModelDataType type,
                                string textureFilePath = null, bool freeze = false)
 {
     return(LoadModel(File.OpenRead(filePath), type, textureFilePath, freeze));
 }
        public static void Populate(ModelDataType type, int count = 10000)
        {
            Max = _iterator = count;
            var rand = new Random();

            switch (type)
            {
            case ModelDataType.Reddit:
                modelId = 12;
                if (_news != null && count >= _news.Count)
                {
                    return;
                }
                var rlist = Builder <RedditModel> .CreateListOfSize(count).All()
                            .With(n => n.Message   = Lorem.Sentence(10))
                            .With(n => n.CreatedBy = Name.FullName(NameFormats.WithPrefix))
                            .With(n => n.Date      = DateTime.Now)
                            .With(n => n.Ids       = Enumerable.Range(1, 10).OrderBy(i => rand.Next()).ToArray())
                            .With(n => n.Op        = Builder <OP> .CreateNew()
                                                     .With(op => op.Age  = rand.Next(1, 100))
                                                     .With(op => op.Name = Faker.Name.FullName(NameFormats.WithSuffix))
                                                     .Build());

                _news = rlist.Build();
                break;

            case ModelDataType.Tweeter:
                modelId = 13;
                if (_tweeter != null && count >= _tweeter.Count)
                {
                    return;
                }
                var tlist = Builder <TweeterModel> .CreateListOfSize(count).All()
                            .With(n => n.completed_in = rand.NextDouble())
                            .With(n => n.max_id       = rand.Next(1000))
                            .With(n => n.next_page    = Faker.Internet.DomainName())
                            .With(n => n.page         = rand.Next(1000))
                            .With(n => n.query        = Faker.Lorem.GetFirstWord())
                            .With(n => n.refresh_url  = Faker.Internet.DomainName())
                            .With(n => n.results      = Builder <Result> .CreateListOfSize(5).All()
                                                        .With(r => r.created_at = DateTime.Now.Subtract(TimeSpan.FromDays(rand.Next(10000)))
                                                                                  .ToString("d"))
                                                        .With(r => r.from_user         = Faker.Name.FullName())
                                                        .With(r => r.from_user_id      = rand.Next())
                                                        .With(r => r.id                = rand.Next())
                                                        .With(r => r.iso_language_code = Faker.Address.ZipCode())
                                                        .With(r => r.metadata          = Builder <Metadata> .CreateNew()
                                                                                         .With(m => m.recent_retweets = rand.Next())
                                                                                         .With(m => m.result_type     = Faker.Lorem.GetFirstWord()).Build())
                                                        .With(r => r.profile_image_url = Faker.Internet.DomainName())
                                                        .With(r => r.source            = Faker.Internet.UserName())
                                                        .With(r => r.text    = Faker.Lorem.Sentence(10))
                                                        .With(r => r.to_user = Faker.Internet.UserName()).Build())
                            .With(n => n.results_per_page = rand.Next(100))
                            .With(n => n.since_id         = rand.Next());

                _tweeter = tlist.Build();
                break;

            case ModelDataType.Youtube:
                modelId = 14;
                if (_youtube != null && count >= _youtube.Count)
                {
                    return;
                }
                var ylist = Builder <YoutubeModel> .CreateListOfSize(count).All()
                            .With(y => y.apiVersion = rand.NextDouble().ToString())
                            .With(y => y.data       = Builder <Data> .CreateNew()
                                                      .With(d => d.accessControl = Builder <AccessControl> .CreateNew()
                                                                                   .With(ac => ac.autoPlay     = RandomNumber.Next(1).ToString())
                                                                                   .With(ac => ac.comment      = Lorem.Sentence(10))
                                                                                   .With(ac => ac.commentVote  = Lorem.Sentence(5))
                                                                                   .With(ac => ac.embed        = rand.Next(1).ToString())
                                                                                   .With(ac => ac.list         = Lorem.Sentence(10))
                                                                                   .With(ac => ac.rate         = rand.Next(1).ToString())
                                                                                   .With(ac => ac.syndicate    = Lorem.GetFirstWord())
                                                                                   .With(ac => ac.videoRespond = Lorem.GetFirstWord()).Build())
                                                      .With(d => d.aspectRatio  = rand.Next(10).ToString() + ":" + rand.Next(10))
                                                      .With(d => d.category     = Lorem.Sentence(2))
                                                      .With(d => d.commentCount = rand.Next(10000))
                                                      .With(d => d.content      = Builder <Content> .CreateNew()
                                                                                  .With(c => c.name = Faker.Lorem.Paragraph(5)).Build())
                                                      .With(d => d.description                                                          = Lorem.Sentence(10))
                                                      .With(d => d.duration                                                             = rand.Next(10000))
                                                      .With(d => d.favoriteCount                                                        = rand.Next(100))
                                                      .With(d => d.id                                                                   = rand.Next().ToString())
                                                      .With(d => d.likeCount                                                            = rand.Next(10000).ToString())
                                                      .With(d => d.player                                                               = Builder <Player> .CreateNew()
                                                                                                              .With(p => p.def          = Lorem.GetFirstWord()).Build())
                                                      .With(d => d.rating                                                               = rand.Next(100))
                                                      .With(d => d.restrictions                                                         = Builder <Restriction> .CreateListOfSize(10).All()
                                                                                                              .With(r => r.countries    = Faker.Address.Country())
                                                                                                              .With(r => r.relationship = Faker.Lorem.GetFirstWord())
                                                                                                              .With(r => r.type         = Lorem.GetFirstWord()).Build())
                                                      .With(d => d.ratingCount                                                          = rand.Next(1000))
                                                      .With(d => d.status                                                               = Builder <Status> .CreateNew()
                                                                                                              .With(s => s.reason       = Faker.Lorem.GetFirstWord())
                                                                                                              .With(s => s.value        = Lorem.GetFirstWord()).Build())
                                                      .With(d => d.tags                                                                 = Faker.Lorem.Words(10).ToList())
                                                      .With(d => d.thumbnail                                                            = Builder <Thumbnail> .CreateNew()
                                                                                                              .With(t => t.hqDefault    = rand.Next(1).ToString())
                                                                                                              .With(t => t.sqDefault    = rand.Next(1).ToString()).Build())
                                                      .With(d => d.title                                                                = Lorem.Sentence(5))
                                                      .With(d => d.updated                                                              = DateTime.Now.Subtract(TimeSpan.FromDays(rand.Next(10000))))
                                                      .With(d => d.uploaded                                                             = DateTime.Now.Subtract(TimeSpan.FromDays(rand.Next(10000))))
                                                      .With(d => d.uploader                                                             = Faker.Name.FullName()).Build());

                _youtube = ylist.Build();

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }