// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using Enyim.Caching; using Enyim.Caching.Configuration; using Enyim.Caching.Memcached; namespace Cache.Memcached.Performance { public class Program { private const int N = 10000; private static void Test(MemcachedClient cache) { // put speed DateTime dt1 = DateTime.Now; for(int i = 0; i < N; i++) { cache.Store(StoreMode.Set, "K#" + (i + 1), i + 1); } DateTime dt2 = DateTime.Now; Console.WriteLine("{0} puts per second", N * 1000 / (int)((dt2 - dt1).TotalMilliseconds)); } private const int REP = 5; public static void Main(string[] args) { MemcachedClientConfiguration cfg = new MemcachedClientConfiguration(); cfg.Protocol = MemcachedProtocol.Binary; cfg.AddServer("localhost:11211"); using(MemcachedClient cache = new MemcachedClient(cfg)) { for(int i = 0; i < REP; i++) { Test(cache); } } } } }