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();
    }
    }

    }

  • 相关阅读:
    Hibernate笔记——(ONE TO ONE)一对一
    Hibernate笔记——第一个简单实例
    Hibernate笔记——Hibernate介绍和初次环境配置
    JavaWeb笔记——ajax异步请求
    Spring笔记——Spring+JDBC组合开发
    Spring笔记——使用Spring进行面向切面(AOP)编程
    Spring笔记——依赖注入
    Java笔记——面向切面编程(AOP模式)
    Spring笔记——Spring框架简介和初次框架配置
    Java产生随机数
  • 原文地址:https://www.cnblogs.com/ericnie/p/5938471.html
Copyright © 2011-2022 走看看