Ejemplo n.º 1
0
        /// <summary>
        /// Generate performance block ranges for a block.
        /// </summary>
        /// <param name="block">The block to generate for.</param>
        /// <returns>A task to monitor the progress.</returns>
        private async Task GeneratePerfRangesForBlock(Func <IBlobCache, int, List <string>, Task <long> > block)
        {
            var results = new Dictionary <int, long>();
            var dbName  = default(string);

            var dirPath = default(string);

            using (Utility.WithEmptyDirectory(out dirPath))
                using (var cache = await GenerateAGiantDatabase(dirPath).ConfigureAwait(false))
                {
                    var keys = await cache.GetAllKeys();

                    dbName = cache.GetType().Name;

                    foreach (var size in PerfHelper.GetPerfRanges())
                    {
                        results[size] = await block(cache, size, keys.ToList()).ConfigureAwait(false);
                    }
                }

            Console.WriteLine(dbName);
            foreach (var kvp in results)
            {
                Console.WriteLine("{0}: {1}", kvp.Key, kvp.Value);
            }
        }
Ejemplo n.º 2
0
        public async Task SequentialBulkWrites()
        {
            await GeneratePerfRangesForBlock(async (cache, size) => {
                var toWrite = PerfHelper.GenerateRandomDatabaseContents(size);

                var st = new Stopwatch();
                st.Start();

                await cache.Insert(toWrite);

                st.Stop();
                return(st.ElapsedMilliseconds);
            });
        }
Ejemplo n.º 3
0
        public async Task ParallelSimpleWrites()
        {
            await GeneratePerfRangesForBlock(async (cache, size) => {
                var toWrite = PerfHelper.GenerateRandomDatabaseContents(size);

                var st = new Stopwatch();
                st.Start();

                await toWrite.ToObservable(BlobCache.TaskpoolScheduler)
                .Select(x => Observable.Defer(() => cache.Insert(x.Key, x.Value)))
                .Merge(32)
                .ToArray();

                st.Stop();
                return(st.ElapsedMilliseconds);
            });
        }
Ejemplo n.º 4
0
        public async Task SequentialSimpleWrites()
        {
            await GeneratePerfRangesForBlock(async (cache, size) => {
                var toWrite = PerfHelper.GenerateRandomDatabaseContents(size);

                var st = new Stopwatch();
                st.Start();

                foreach (var kvp in toWrite)
                {
                    await cache.Insert(kvp.Key, kvp.Value);
                }

                st.Stop();
                return(st.ElapsedMilliseconds);
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates a giant database.
        /// </summary>
        /// <param name="path">A path to use for generating it.</param>
        /// <returns>The blob cache.</returns>
        private async Task <IBlobCache> GenerateAGiantDatabase(string path)
        {
            path ??= IntegrationTestHelper.GetIntegrationTestRootDirectory();

            var giantDbSize = PerfHelper.GetPerfRanges().Last();
            var cache       = CreateBlobCache(path);

            var keys = await cache.GetAllKeys();

            if (keys.Count() == giantDbSize)
            {
                return(cache);
            }

            await cache.InvalidateAll();

            await PerfHelper.GenerateDatabase(cache, giantDbSize).ConfigureAwait(false);

            return(cache);
        }
Ejemplo n.º 6
0
        public async Task GeneratePerfRangesForBlock(Func <IBlobCache, int, Task <long> > block)
        {
            var results = new Dictionary <int, long>();
            var dbName  = default(string);

            var dirPath = default(string);

            using (Utility.WithEmptyDirectory(out dirPath))
                using (var cache = CreateBlobCache(dirPath))
                {
                    dbName = dbName ?? cache.GetType().Name;

                    foreach (var size in PerfHelper.GetPerfRanges())
                    {
                        results[size] = await block(cache, size);
                    }
                }

            Console.WriteLine(dbName);
            foreach (var kvp in results)
            {
                Console.WriteLine("{0}: {1}", kvp.Key, kvp.Value);
            }
        }