コード例 #1
0
        public static async Task Write100KbByteArrays(int numberOfChunks, string cachename = null)
        {
            var byteArrays = PerfHelpers.GetByteArrays(numberOfChunks);

            using (var cache = await DesktopCacheFactory.GetCache(null, cachename ?? PerfCacheName))
            {
                await cache.Clear();

                var sw = Stopwatch.StartNew();
                for (var i = 0; i < byteArrays.Length; i++)
                {
                    cache.Set(i.ToString(), byteArrays[i]).Wait();
                }
                sw.Stop();
                Console.WriteLine("Elapsed:" + sw.ElapsedMilliseconds);
            }
        }
コード例 #2
0
        public static async Task Get100KbByteArrays(int numberOfChunks)
        {
            var byteArrays = PerfHelpers.GetByteArrays(numberOfChunks);
            var cache      = await DesktopCacheFactory.GetCache(null, PerfCacheName);

            await cache.Clear();

            var length = byteArrays.Length;

            for (var i = 0; i < length; i++)
            {
                cache.Set(i.ToString(), byteArrays[i]).Wait();
            }
            var sw = Stopwatch.StartNew();

            for (var i = 0; i < length; i++)
            {
                cache.Get <byte[]>(i.ToString()).Wait();
                //bytes.Value.Should().HaveCount(102400);
            }
            sw.Stop();
            Console.WriteLine("Elapsed on get:" + sw.ElapsedMilliseconds);
        }