Ejemplo n.º 1
0
		private static void WriteToDatabase(List<Observing<User>> sources, Random random, CreateIndexes createIndexes)
		{
			int count = 0;
			while (sources.Any(x => x.Completed == false))
			{
				var sizes = sources.Select(_ => random.Next(1, 40)).ToList();
				count++;
				Parallel.ForEach(sources, (observing, state, i) =>
				{
					if (count%3 == 0) // do writes only every third run, ensure more reads than writes (more production)
					{
						observing.Release(sizes[(int) i]);
					}
					createIndexes.DoSomeOtherWork((int)i);
				});

				createIndexes.CreateIndexesSecond();

				Thread.Sleep(random.Next(50, 150));

				if (count%100 == 0)
				{
					createIndexes.Stats();
				}
			}
		}
Ejemplo n.º 2
0
        private static void Main()
        {
            using (var documentStore = new DocumentStore
            {
                ConnectionStringName = "RavenDB"
            })
            {
                documentStore.Initialize();
                var createIndexes = new CreateIndexes(documentStore);
                var random        = new Random(95832);

                var sources = GenerateSources(random, documentStore);

                WriteToDatabase(sources, random, createIndexes);
            }
        }
Ejemplo n.º 3
0
		private static void Main()
		{
			using (var documentStore = new DocumentStore
			{
				ConnectionStringName = "RavenDB"
			})
			{
				documentStore.Initialize();
				var createIndexes = new CreateIndexes(documentStore);
				var random = new Random(95832);

				var sources = GenerateSources(random, documentStore);

				WriteToDatabase(sources, random, createIndexes);
			}
		}
Ejemplo n.º 4
0
        private static void WriteToDatabase(List <Observing <User> > sources, Random random, CreateIndexes createIndexes)
        {
            int count = 0;

            while (sources.Any(x => x.Completed == false))
            {
                var sizes = sources.Select(_ => random.Next(1, 40)).ToList();
                count++;
                Parallel.ForEach(sources, (observing, state, i) =>
                {
                    if (count % 3 == 0)                   // do writes only every third run, ensure more reads than writes (more production)
                    {
                        observing.Release(sizes[(int)i]);
                    }
                    createIndexes.DoSomeOtherWork((int)i);
                });

                createIndexes.CreateIndexesSecond();

                Thread.Sleep(random.Next(50, 150));

                if (count % 100 == 0)
                {
                    createIndexes.Stats();
                }
            }
        }