anchor.diff:  
   import 'dart:async';
   import 'dart:convert';
  +import 'dart:collection';
   import '../lib/redis.dart';
   
   
  
positive.code:   });
  }
  
  main(){
    test_pubsub();
  }
negative.code:   });
  }
  
  test_performance2(){
      const int N = 200000;
      int start;
      RedisConnection conn = new RedisConnection();
      conn.connect('localhost',6379).then((Command command){
        print("test started, please wait ...");
        start =  new DateTime.now().millisecondsSinceEpoch;
        command.pipe_start();
        command.set("test","0");
        for(int i=1;i<=N;i++){ 
          command.send_object(["INCR","test"])
          .then((v){
            if(i != v)
              throw("wrong received value, we got $v");
          });
        }
        //last command will be executed and then processed last
        command.get("test").then((v){
          print(v); 
          double diff = (new DateTime.now().millisecondsSinceEpoch - start)/1000.0;
          double perf = N/diff;
          print("$N operations done in $diff s\nperformance $perf/s");
        });
        command.pipe_end();
      });
  }
  
  test_muliconnections(){
    const int N = 2000000;
    const int K = 10;
    int start;
    int c=0;
    
    print("test started, please wait ...");
    start =  new DateTime.now().millisecondsSinceEpoch;
    RedisConnection conn = new RedisConnection();
    conn.connect('localhost',6379).then((Command command){
      return command.set("var","0");
    })
    .then((_){
      for(int j=0;j<K;j++){
        RedisConnection conn = new RedisConnection();
        conn.connect('localhost',6379).then((Command command){
          command.pipe_start();
          for(int i=j;i<N;i+=K){ 
            command.send_object(["INCR","var"])
            .then((v){
              c++;
              if(c==N){
                double diff = (new DateTime.now().millisecondsSinceEpoch - start)/1000.0;
                double perf = N/diff;
                print("$N operations done in $diff s\nperformance $perf/s");
                command.get("var").then((v){print("var is $v");});
              }
            });
          }
          command.pipe_end();
        });
      }
    });
  }
  
  
  test_transactions(){
    RedisConnection conn = new RedisConnection();
    RedisConnection conn2 = new RedisConnection();
    int N=2000000;
    conn.connect('localhost',6379).then((Command command){   
      conn2.connect('localhost',6379).then((Command command2){ 
        command.multi().then((Transaction trans){
            trans.send_object(["SET","val","0"]);
            for(int i=1;i<=N;++i){
              trans.send_object(["INCR","val"]).then((v){
                assert(v==i);
              });
              command2.send_object(["INCR","val"]).then((v){
                assert(true);
              });
            }
            trans.send_object(["GET","val"]).then((v){
              print("number is now $v");
            });
            command2.send_object(["GET","val"]).then((v){
              print("number2 is now $v");
            });
            trans.exec();
        });
      });
    });
  }
  