zoukankan      html  css  js  c++  java
  • 缓存的压力测试脚本

    贴一段Coherence压力测试脚本,在不需要部署web应用的情况下,直接在命令行进行压力测试

    测试脚本启动100个Thread(ParallelTreadCount),然后每个thread运行500次(2000次读和100次写).

    这100个thread会直接压到集群的其中一个代理节点上(proxy),所以保证proxy的thread配置>100.

    package coherencetest;
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.ConfigurableCacheFactory;
    import com.tangosol.net.DefaultConfigurableCacheFactory;
    import com.tangosol.net.NamedCache;

     

    public class CoherenceCachePut implements Runnable {
    private final ClassLoader loader = null;
    NamedCache cache;

    static int m_loop=100;
    static int ParallelTreadCount =100;


    public CoherenceCachePut() {
    super();
    }



    public void run() {

    long threadid = Thread.currentThread().getId();
    NamedCache cache;
    cache = CacheFactory.getCache("POFSample");
    String AA = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
    String a = "AAA";

    for (int j=0;j<500;j++) {
    for (int i=0;i<1000;i++) {
    a = (String)cache.get(i);
    }

    for (int i=0;i<100;i++) {
    cache.put(100-i,a);
    }

    for (int i=0;i<1000;i++) {
    a = (String)cache.get(i);
    }

    }
    }



    public CoherenceCachePut(int loop) {
    this.m_loop = loop;

    }

    public static void main (String [] args) {

    NamedCache cache;
    cache = CacheFactory.getCache("POFSample");
    String AA = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";


    for (int i=0;i<1000;i++) {
    cache.put (i, "CacheValue="+AA+i);
    }

    int loop;

    loop=m_loop;
    for(int i=0; i<ParallelTreadCount; i++)
    {
    new Thread(new CoherenceCachePut(loop)).start();
    }
    }

    }

  • 相关阅读:
    自学android半年,已从.net转型成android程序员,分享下这个过程(转)
    深入浅出jsonp
    对程序员说点实在话(转)
    浅谈iOS学习之路(转)
    Quartz Cron表达式 在线生成器
    AutoMapper使用笔记
    毕业两年工作三年小结
    C#转C++的一点分享
    手机数据抓包以及wireshark技巧
    这些.NET开源项目你知道吗?让.NET开源来得更加猛烈些吧。。。(转)
  • 原文地址:https://www.cnblogs.com/ericnie/p/5938471.html
Copyright © 2011-2022 走看看