有时候需要快速验证不同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