// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using StackExchange.Redis; namespace Cache.Redis.Performance { public class Program { private const int N = 10000; private static void Test(IDatabase cache) { // put speed DateTime dt1 = DateTime.Now; for (int i = 0; i < N; i++) { cache.StringSet("K#" + (i + 1), i + 1); } DateTime dt2 = DateTime.Now; Console.WriteLine("{0} puts per second", N * 1000 / (int)((dt2 - dt1).TotalMilliseconds)); } private const int PERFORMANCE_CACHE = 1; private const int REP = 5; public static void Main(string[] args) { ConnectionMultiplexer con = ConnectionMultiplexer.Connect("localhost:6379"); IDatabase cache = con.GetDatabase(PERFORMANCE_CACHE); for (int i = 0; i < REP; i++) { Test(cache); } } } }