示例#1
0
        public void Execute()
        {
            var watch      = Stopwatch.StartNew();
            var iterations = 1000;
            var elements   = 20;

            for (int i = 0; i < iterations; i++)
            {
                var key  = i.ToString();
                var vals = new List <Tuple <string, Tx> >();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    vals.Add(new Tuple <string, Tx>(key, original));
                }
                var addResults = Redis.SAdd(vals);
                //var returned = Redis.SPop<Tx>(key);
            }
            watch.Stop();
            "Read and wrote {0} sets with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
            .ToDebug <RedisDemo>(
                iterations,
                watch.ElapsedMilliseconds,
                (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
                watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
                elements);
            "Flushing"
            .ToDebug <RedisDemo>();
            Redis.FlushAll();
        }
示例#2
0
        public void Execute()
        {
            var watch      = Stopwatch.StartNew();
            var iterations = 1000;
            var elements   = 20;

            for (int i = 0; i < iterations; i++)
            {
                var key          = i.ToString();
                var originalDict = new Dictionary <string, Tx>();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    var field    = j.ToString();
                    originalDict.Add(field, original);
                }
                Redis.HSet <Tx>(key, originalDict);
                var keyList = Redis.HVals <Tx>(key);
            }
            watch.Stop();
            "Wrote {0} lists with {4} elements each and got keys in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
            .ToDebug <RedisDemo>(
                iterations,
                watch.ElapsedMilliseconds,
                (iterations * elements) / watch.Elapsed.TotalSeconds,
                watch.Elapsed.TotalMilliseconds / (iterations * elements),
                elements);
            "Flushing"
            .ToDebug <RedisDemo>();
            Redis.FlushAll();
        }
示例#3
0
        public void Execute()
        {
            var watch      = Stopwatch.StartNew();
            var iterations = 1000;
            var elements   = 20;

            for (int i = 0; i < iterations; i++)
            {
                var key = i.ToString();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    var field    = j.ToString();
                    Redis.HSet(key, field, original);
                    var returned = Redis.HGet <Tx>(key, field);
                    //List<string> lst = new List<string>();
                    //lst.Add(field);
                    //var returned = Redis.HGet<Tx>(key, lst);
                }
            }
            watch.Stop();
            "Read and wrote {0} lists with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
            .ToDebug <RedisDemo>(
                iterations,
                watch.ElapsedMilliseconds,
                (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
                watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
                elements);
            "Flushing"
            .ToDebug <RedisDemo>();
            Redis.FlushAll();
        }
示例#4
0
        public void Execute()
        {
            var watch      = Stopwatch.StartNew();
            var iterations = 10000;

            for (int i = 0; i < iterations; i++)
            {
                var key      = i.ToString();
                var original = new Tx(i);
                Redis.LPush(key, original);
                var value = Redis.RPop <Tx>(key);
                if (!value.Equals(original))
                {
                    "Write / Read operation fail!!!"
                    .ToError <RedisDemo>();
                    throw new Exception("Read fail :( :( :(");
                }
            }
            watch.Stop();
            "Read and wrote {0} records in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
            .ToDebug <RedisDemo>(
                iterations,
                watch.ElapsedMilliseconds,
                (iterations * 2) / watch.Elapsed.TotalSeconds,
                watch.Elapsed.TotalMilliseconds / (iterations * 2));
            "Flushing"
            .ToDebug <RedisDemo>();
            Redis.FlushAll();
        }
示例#5
0
        public void Execute()
        {
            var watch      = Stopwatch.StartNew();
            var iterations = 1000;
            var elements   = 20;

            for (int i = 0; i < iterations; i++)
            {
                var key = i.ToString();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    Redis.RPush(key, original);
                }
                var rng = Redis.LRange <Tx>(key, 0, elements);
            }
            watch.Stop();
            "Read and wrote {0} lists with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
            .ToDebug <RedisDemo>(
                iterations,
                watch.ElapsedMilliseconds,
                (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
                watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
                elements);
            "Flushing"
            .ToDebug <RedisDemo>();
            Redis.FlushAll();
        }
示例#6
0
        protected void ReadWrite(int i)
        {
            var key      = i.ToString();
            var original = new Tx(i);

            Redis.Set(key, original);
            var value = Redis.Get <Tx>(key);

            if (!value.Equals(original))
            {
                "Write / Read operation fail!!!"
                .ToError <RedisDemo>();
                throw new Exception("Read fail :( :( :(");
            }
        }
示例#7
0
 public void Execute()
 {
     var watch = Stopwatch.StartNew();
     var iterations = 1000000;
     for (int i = 0; i < iterations; i++)
     {
         var key = i.ToString();
         var original = new Tx(i);
         Redis.Set(key, original);
         var value = Redis.Get<Tx>(key);
         if (!value.Equals(original))
         {
             "Write / Read operation fail!!!"
                 .ToError<RedisDemo>();
             throw new Exception("Read fail :( :( :(");
         }
     }
     watch.Stop();
     "Read and wrote {0} records in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
         .ToDebug<RedisDemo>(
             iterations,
             watch.ElapsedMilliseconds,
             (iterations * 2) / watch.Elapsed.TotalSeconds,
             watch.Elapsed.TotalMilliseconds / (iterations * 2));
     "Flushing"
         .ToDebug<RedisDemo>();
     Redis.FlushAll();
 }
示例#8
0
        public void Execute()
        {
            var watch = Stopwatch.StartNew();
            var iterations = 1000;
            var elements = 20;
            for (int i = 0; i < iterations; i++)
            {
                var key = i.ToString();
                var vals = new List<Tuple<string,Tx>>();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    vals.Add(new Tuple<string, Tx>(key,original));

                }
                var addResults = Redis.SAdd(vals);
                //var returned = Redis.SPop<Tx>(key);
            }
            watch.Stop();
            "Read and wrote {0} sets with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
                .ToDebug<RedisDemo>(
                    iterations,
                    watch.ElapsedMilliseconds,
                    (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
                    watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
                    elements);
            "Flushing"
                .ToDebug<RedisDemo>();
            Redis.FlushAll();
        }
示例#9
0
        public void Execute()
        {
            var watch = Stopwatch.StartNew();
            var iterations = 1000;
            var elements = 20;
            for (int i = 0; i < iterations; i++)
            {
                var key = i.ToString();
                var originalDict = new Dictionary<string, Tx>();
                for (int j = 0; j < elements; j++)
                {
                    var original = new Tx(i * iterations + j);
                    var field = j.ToString();
                    originalDict.Add(field, original);

                }
                Redis.HSet<Tx>(key, originalDict);
                var keyList = Redis.HVals<Tx>(key);
            }
            watch.Stop();
            "Wrote {0} lists with {4} elements each and got keys in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
                .ToDebug<RedisDemo>(
                    iterations,
                    watch.ElapsedMilliseconds,
                    (iterations * elements) / watch.Elapsed.TotalSeconds,
                    watch.Elapsed.TotalMilliseconds / (iterations * elements),
                    elements);
            "Flushing"
                .ToDebug<RedisDemo>();
            Redis.FlushAll();
        }
示例#10
0
 public void Execute()
 {
     var watch = Stopwatch.StartNew();
     var iterations = 1000;
     var elements = 20;
     for (int i = 0; i < iterations; i++)
     {
         var key = i.ToString();
         for (int j = 0; j < elements; j++)
         {
             var original = new Tx(i * iterations + j);
             var field = j.ToString();
             Redis.HSet(key, field, original);
             var returned = Redis.HGet<Tx>(key, field);
             //List<string> lst = new List<string>();
             //lst.Add(field);
             //var returned = Redis.HGet<Tx>(key, lst);
         }
     }
     watch.Stop();
     "Read and wrote {0} lists with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
         .ToDebug<RedisDemo>(
             iterations,
             watch.ElapsedMilliseconds,
             (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
             watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
             elements);
     "Flushing"
         .ToDebug<RedisDemo>();
     Redis.FlushAll();
 }
示例#11
0
 public void Execute()
 {
     var watch = Stopwatch.StartNew();
     var iterations = 1000;
     var elements = 20;
     for (int i = 0; i < iterations; i++)
     {
         var key = i.ToString();
         for (int j = 0; j < elements; j++)
         {
             var original = new Tx(i*iterations + j);
             Redis.RPush(key, original);
         }
         var rng = Redis.LRange<Tx>(key, 0, elements);
     }
     watch.Stop();
     "Read and wrote {0} lists with {4} elements each in {1} miliseconds. \r\n\t{2} read/write ops per second.\r\n\t{3} miliseconds per operation."
         .ToDebug<RedisDemo>(
             iterations,
             watch.ElapsedMilliseconds,
             (iterations * 2 * elements) / watch.Elapsed.TotalSeconds,
             watch.Elapsed.TotalMilliseconds / (iterations * 2 * elements),
             elements);
     "Flushing"
         .ToDebug<RedisDemo>();
     Redis.FlushAll();
 }
示例#12
0
 protected void ReadWrite(int i)
 {
     var key = i.ToString();
     var original = new Tx(i);
     Redis.Set(key, original);
     var value = Redis.Get<Tx>(key);
     if (!value.Equals(original))
     {
         "Write / Read operation fail!!!"
             .ToError<RedisDemo>();
         throw new Exception("Read fail :( :( :(");
     }
 }