Oracle Load Testing

import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Date;

import java.util.Enumeration;

import java.util.HashMap;

import java.util.List;

import java.util.Properties;

import oracle.oats.scripting.modules.basic.api.ScriptService;

/**

*

*/

/**

* @author 420309

*

*/

public class MyDatabank {

private static HashMap<String,int[]> DBDesc = new HashMap<String,int[]>();

private static List<String[]> DBList = new ArrayList<String[]>();

private static String logFile = null;

private static OutputStreamWriter logger = null;

@ScriptService oracle.oats.scripting.modules.http.api.HTTPService http;

@ScriptService oracle.oats.scripting.modules.adfload.api.AdfLoadService adfload;

public static synchronized void setLog(String file)throws Exception{

if(logger != null) return;

logFile = file;

logger = new OutputStreamWriter(new FileOutputStream(file));

}

public static synchronized void log(String str)throws Exception{

if(logFile == null)return;

if(logger == null){

logger = new OutputStreamWriter(new FileOutputStream(logFile));

}

//String time = new Date().getTime();

logger.write(new Date().getTime() + ":" + str + "\r\n");

logger.flush();

}

// synchronized 防止多个线程重复加载

public static synchronized void initDatabank(String fileCSV)throws Exception{

if(DBList.size() > 0) return;//是否已经加载数据,防止多线程下多次加载

log("initDatabank:"+fileCSV);

BufferedReader br = new BufferedReader(new InputStreamReader(

new FileInputStream(fileCSV)));

String rec = null;

try {

br.readLine();//Ignore CSV Header

while ((rec = br.readLine()) != null) {

//System.out.println("line:"+rec);

String[] cells = rec.split(",");

DBList.add(cells);

}

} catch (Exception e) {

throw e;

} finally {

if (br != null) {

br.close();

}

}

}

//LINE:based-1

public static synchronized void initDatabankDesc(String fileDesc)throws Exception{

if(DBDesc.size() > 0) return;

log("initDatabankDesc:"+fileDesc);

Properties props = new Properties();

props.load(new FileInputStream(fileDesc));

Enumeration<String> enums = (Enumeration<String>)props.propertyNames();

String name = null;

String value = null;

int idx = -1;

int s,e;

while(enums.hasMoreElements()){

name = enums.nextElement();

value = props.getProperty(name).trim();

idx = value.indexOf(‘,‘);

if(idx == -1) throw new Exception("File Format Error,‘,‘ Not Found");

s = Integer.parseInt(value.substring(0,idx)) - 1;//based-0

e = Integer.parseInt(value.substring(idx+1)) - 1;//based-0

int[] flag = new int[]{s,e,0};//[s,e]idx-0

//System.out.println("********s:"+s+",e:"+e);

//System.out.println("********name:"+name);

DBDesc.put(name, flag);

}

}

//col:based-0

public static String getNextDatabank(String name,int col)throws Exception{

int[] flag = DBDesc.get(name);

if(flag == null) throw new Exception("Name:["+name+"] Not Found");

Object obj = new Object();

int idx = -1;

synchronized(obj){

idx = flag[0]+flag[2];

if(idx > flag[1]) {

idx = flag[0];

flag[2] = 0;

}

flag[2]++;

}

String[] cells = DBList.get(idx);

if(cells == null)throw new Exception("Name:["+name+"],Row:["+(idx + 1)+"] Not Found");

log("getNextDatabank:name["+name+"],idx["+idx+"],col["+col+"] = ["+cells[col]+"]");

return cells[col];

}

public static int getDatabankCount(String name)throws Exception{

int[] flag = DBDesc.get(name);

if(flag == null) throw new Exception("Name:["+name+"] Not Found");

int count = flag[1] - flag[0] + 1;

log("getDatabankCount:"+count);

return count;

}

}

时间: 2024-08-09 06:27:08

Oracle Load Testing的相关文章

JMeter Don&#39;t use GUI mode for load testing!

安装好JMeter后,运行JMeter.bat,会出现两个界面,一个命令行界面(NON GUI Mode),一个图形化界面(GUI Mode) 在命令行界面中提示: Don't use GUI mode for load testing, only for Test creation and Test debugging.For load testing, use NON GUI Mode:   jmeter -n -t [jmx file] -l [results file] -e -o [P

Load Testing Socket.IO Web Applications and Infrastructure

转自:https://medium.com/better-programming/load-testing-socket-io-web-applications-and-infrastructure-3e96011898e0 关于artillery的一个实践 Are you shipping a scalable real-time back end? This article provides a tutorial for load testing your Socket.IO-based W

FDA Approves First Hepatitis B Viral Load Test on 2007

FDA Approves First Hepatitis B Viral Load Test Another Roche first in TaqMan real-time PCR testing for the diagnostic lab The U.S. Food & Drug Administration (FDA) has approved the Roche COBAS TaqManHBV Test, the first assay for quantitating hepatiti

oracle的高可用与负载均衡

浏览了一下Oracle官方的网页以及非官方的ppt,简单了解了一下Oracle提供的高可用方案.1. RACRAC,  Real Application Clusters多个Oracle服务器组成一个共享的Cache,而这些Oracle服务器共享一个基于网络的存储.这个系统可以容忍单机/或是多机失败.不过系统内部的多个节点需要高速网络互连,基本上也就是要全部东西放在在一个机房内,或者说一个数据中心内.如果机房出故障,比如网络不通,那就坏了.所以仅仅用RAC还是满足不了一般互联网公司的重要业务的需

Performance testing test scenarios

1 check if page load time is within acceptable range2 check page load on slow connections 3 check response time for any action under light, normal, moderate and heavy load conditions4 check performance of database stored procedures and triggers5 chec

Testing Complex Logic with JMeter Beanshell

BeanShell是最先进的JMeter内置组件之一.JMeter具有丰富的内置插件,可满足性能测试的许多需求.例如,在编写一些复杂的测试时,您可能需要一些额外的脚本.在这种情况下,值得使用Beanshell.在这篇文章中,我们将讨论使用JMeter Beanshell和常见用例测试复杂逻辑.Beanshell具有运行Java代码的功能,并且可以访问JMeter API和在JMeter类路径中加载的外部类. JMeter具有以下启用Beanshell的组件: Beanshell采样器. Bean

Python框架、库以及软件资源汇总

转自:http://developer.51cto.com/art/201507/483510.htm 很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世界各地的程序员们都能够贡献他们的代码与创新. Python就是这样一门受到全世界各地开源社区支持的语言.Python可以用来开发各种小工具软件.web应用.科学计算.数据分析等等,Python拥有大量的流行框架,比如Django.使用Python框架时,可以根据自己的需求插入不同的模块,比如可以用S

软件性能测试指标及其注意地方

并发性能测试的种类与指标 并发性能测试的种类取决于并发性能测试工具监控的对象,以QALoad自动化负载测试工具为例.软 件针对各种测试目标提供了DB2.DCOM.ODBC.ORACLE.NETLoad.Corba.QARun.SAP.SQLServer. Sybase.Telnet.TUXEDO.UNIFACE.WinSock.WWW.Java scrīpt等不同的监控对象,支持Windows和UNIX测试环境. 最关键的仍然是测试过程中对监控对象的灵活应用,例如目前三层结构的运行模式广泛使用,

Development Tools

Introduction Even Chris created his article of Useful Reference Books ages ago I just bumped into it, and after adding my bit I thought to do something similar in the field of development tools. So feel free and add tools you found useful in your car