zoukankan      html  css  js  c++  java
  • redis的Pipelined的实验

    Pipelined 一千条插入一次 SET: 1.648 seconds
    普通模式Pipelined SET: 43.665 seconds
    Pipelined 一千条插入一次 SET: 2.153 seconds
    普通模式Pipelined SET: 54.158 seconds
    Pipelined 一千条插入一次 SET: 2.656 seconds
    普通模式Pipelined SET: 53.896 seconds
    Pipelined 一千条插入一次 SET: 1.512 seconds
    普通模式Pipelined SET: 42.119 seconds
    Pipelined 一千条插入一次 SET: 1.952 seconds
    普通模式Pipelined SET: 39.732 seconds
    Pipelined 一千条插入一次 SET: 2.031 seconds
    普通模式Pipelined SET: 41.751 seconds
    Pipelined 一千条插入一次 SET: 2.283 seconds
    普通模式Pipelined SET: 40.043 seconds
    Pipelined 一千条插入一次 SET: 2.18 seconds
    普通模式Pipelined SET: 38.206 seconds
    Pipelined 一千条插入一次 SET: 1.687 seconds
    普通模式Pipelined SET: 40.043 seconds
    Pipelined 一千条插入一次 SET: 1.66 seconds
    普通模式Pipelined SET: 44.61 seconds
    Pipelined 一千条插入一次 SET: 2.496 seconds
    普通模式Pipelined SET: 49.562 seconds
    Pipelined 一千条插入一次 SET: 1.833 seconds
    普通模式Pipelined SET: 40.938 seconds
    Pipelined 一千条插入一次 SET: 1.839 seconds
    普通模式Pipelined SET: 40.364 seconds


    代码:
    Pipeline pipeline = JedisUtil.getPipeline();
    //kasher redis
    public void testPMain(List l) throws Exception{

    for (int i = 0; i < 100; i++) {
    testP(l);
    testP1(l);
    pipeline.close();
    }
    }
    public void testP(List l) throws Exception{
    //Pipeline pipeline = JedisUtil.getPipeline();
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
    pipeline.set(SerializeUtil.serialize("p" + i), SerializeUtil.serialize(l));
    //List<Object> results = pipeline.syncAndReturnAll(); // ---- 1
    }
    List<Object> results = pipeline.syncAndReturnAll(); // ------2
    long end = System.currentTimeMillis();
    System.out.println("Pipelined 一千条插入一次 SET: " + ((end - start)/1000.0) + " seconds");
    System.out.println(SerializeUtil.unserialize(JedisUtil.get(SerializeUtil.serialize("p6"))));
    //pipeline.close();
    }
    public void testP1(List l) throws Exception{
    //Pipeline pipeline = JedisUtil.getPipeline();
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
    pipeline.set(SerializeUtil.serialize("p" + i), SerializeUtil.serialize(l));
    List<Object> results = pipeline.syncAndReturnAll(); // ---- 1
    }
    //List<Object> results = pipeline.syncAndReturnAll(); // ------2
    long end = System.currentTimeMillis();
    System.out.println("普通模式Pipelined SET: " + ((end - start)/1000.0) + " seconds");
    System.out.println(SerializeUtil.unserialize(JedisUtil.get(SerializeUtil.serialize("p6"))));
    //pipeline.close();
    }

  • 相关阅读:
    NYOJ 625 笨蛋的难题(二)
    NYOJ 102 次方求模
    ZJU Least Common Multiple
    ZJUOJ 1073 Round and Round We Go
    NYOJ 709 异形卵
    HDU 1279 验证角谷猜想
    BNUOJ 1015 信息战(一)——加密程序
    HDU 1202 The calculation of GPA
    "蓝桥杯“基础练习:字母图形
    "蓝桥杯“基础练习:数列特征
  • 原文地址:https://www.cnblogs.com/kasher/p/7163749.html
Copyright © 2011-2022 走看看