PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1936 oracle 15 0 1681m 26m 22m S 0.0 0.2 0:00.13 oracle
1906 oracle 15 0 1681m 26m 22m S 0.0 0.2 0:00.14 oracle
1955 oracle 15 0 1681m 26m 22m S 0.0 0.2 0:00.12 oracle
1940 oracle 15 0 1681m 26m 22m S 0.0 0.2 0:00.15 oracle
这里 RES的值*个数<总内存。
呵呵,结束了,简单吧。
新的补充
今天把python脚本补充一下,之前一个进程一个连接,那我要测1000个连接,不是要启动1000进程吗?这样太恐怖了,是不要要多线程呢?当然要了,我们在更新一个python代码
#! /usr/bin/python#coding=UTF-8import cx_Oracleimport timeimport sysimport loggingimport logging.configimport threadingfrom optparse import OptionParserdef hello():'''Hello cx_Oracle示例:1)打印数据库版本信息.2)查询表数据.'''conn = cx_Oracle.connect("jscn/jscn@192.168.100.199:1521/jscn")cur = conn.cursor()try:print "Oracle Version:%s" % conn.versionprint "Table SUB_POLICY rows:"interger = 1while interger <= 30000000:sql="select * from product PRODUCT_ID= '0lea940'"sql1="select * from productcategory where CATEGORY_ID='xhn6238'"cur.execute(sql)for row in cur:print rowtime.sleep(1)cur.execute(sql1)for row in cur:print rowtime.sleep(10) interger = interger + 1finally:cur.close()conn.close()def _handleCmdLine(args):parser = OptionParser()parser.add_option("--threadnum", dest="threadnum",action="store", type="int", default=10,help="thread num")(options, args) = parser.parse_args(args)return (options,args)class TestThread(threading.Thread):def run(self):while True:hello()def main():options,args=_handleCmdLine(sys.argv)threads=[]for i in range(options.threadnum):th=TestThread()threads.append(th)th.setDaemon(True)th.start()for t in threads:t.join()if __name__ == '__main__':#logging.exception("main except")try:main()except Exception:logging.exception("main except")
如何执行呢?比如我们把脚本叫test.py
在dos界面输入:
C:\Users\jscn-xw\Desktop>python test.py -hUsage: test.py [options]Options:-h, --help show this help message and exit--threadnum=THREADNUMthread num
比如我们要输入进程为300个
C:\Users\jscn-xw\Desktop>python test.py --threadnum=300
现在已经进程就可以跑300个连接了。