快速验证jvm gc的测试脚本

8 篇文章 0 订阅
5 篇文章 0 订阅

有时候需要快速验证不同GC配置的效果,下面是dboss的一个测试脚本,足够简单,但有足够测试gc的变化情况。

 

 

from java.util.concurrent import Executors
from java.util.concurrent import Callable

DBOSS={
 "dboss":{
    "locations":["192.168.172.3:9999"],
    "references":[
        {
            "id":"dbossTester",
            "version":"1.0"
        }
    ]
  },
}
from dboss import  DuitangRemoteProxy
proxy = DuitangRemoteProxy(DBOSS)
dbossTester = proxy.getService('dbossTester')
import time
data="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
for x in range(2000):
    dbossTester.test(data)

executor =  Executors.newFixedThreadPool(50)

class Tester(Callable):
        def call(self):
            dbossTester.test(data)
        
tasklist = []
for x in range(500000):
    tasklist.append(Tester())

begin = time.time()    
resultlist = executor.invokeAll(tasklist)
for result in resultlist:
        result.get()
end = time.time()
print "50 concurrent, 500000 rquest cost %s"%((end-begin)*1000)        
executor.shutdown()

 测试不同的gc配置

 

默认gc
[admin@server3 dboss-test]$ /duitang/dist/sys/java/bin/java -XX:NewRatio=3 -XX:+UseCompressedOops -XX:+DisableExplicitGC -Xmx1g -Xss1024k -Xms1g -classpath /duitang/dist/sys/jython/jython.jar: -Dpython.home=/duitang/dist/sys/jython -Dpython.executable=/duitang/dist/sys/jython/bin/jython org.python.util.jython dboss_con_test3.py

 

cms
[admin@server3 dboss-test]$ /duitang/dist/sys/java/bin/java -XX:NewRatio=3 -XX:+UseCompressedOops -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalSafetyFactor=75 -XX:CMSInitiatingPermOccupancyFraction=90 -XX:CMSIncrementalDutyCycle=10 -XX:CMSIncrementalDutyCycleMin=0 -Xmx1g -Xss1024k -Xms1g -classpath /duitang/dist/sys/jython/jython.jar: -Dpython.home=/duitang/dist/sys/jython -Dpython.executable=/duitang/dist/sys/jython/bin/jython org.python.util.jython dboss_con_test3.py

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值