亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? microperformanceregressiontest.java

?? 用于JAVA數據庫連接.解壓就可用,方便得很
?? JAVA
字號:
/*
 Copyright (C) 2002-2004 MySQL AB

 This program is free software; you can redistribute it and/or modify
 it under the terms of version 2 of the GNU General Public License as 
 published by the Free Software Foundation.

 There are special exceptions to the terms and conditions of the GPL 
 as it is applied to this software. View the full text of the 
 exception in file EXCEPTIONS-CONNECTOR-J in the directory of this 
 software distribution.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



 */
package testsuite.regression;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import testsuite.BaseTestCase;

/**
 * Microperformance benchmarks to track increase/decrease in performance of core
 * methods in the driver over time.
 * 
 * @author Mark Matthews
 * 
 * @version $Id: MicroPerformanceRegressionTest.java,v 1.1.2.1 2005/05/13
 *          18:58:38 mmatthews Exp $
 */
public class MicroPerformanceRegressionTest extends BaseTestCase {

	private double scaleFactor = 1.0;

	private final static int ORIGINAL_LOOP_TIME_MS = 2300;

	private final static double LEEWAY = 3.0;

	private final static Map BASELINE_TIMES = new HashMap();

	static {
		BASELINE_TIMES.put("ResultSet.getInt()", new Double(0.00661));
		BASELINE_TIMES.put("ResultSet.getDouble()", new Double(0.00671));
		BASELINE_TIMES.put("ResultSet.getTime()", new Double(0.02033));
		BASELINE_TIMES.put("ResultSet.getTimestamp()", new Double(0.02363));
		BASELINE_TIMES.put("ResultSet.getDate()", new Double(0.02223));
		BASELINE_TIMES.put("ResultSet.getString()", new Double(0.00982));
		BASELINE_TIMES.put("ResultSet.getObject() on a string", new Double(
				0.00861));
		BASELINE_TIMES
				.put("Connection.prepareStatement()", new Double(0.18547));
		BASELINE_TIMES.put("PreparedStatement.setInt()", new Double(0.0011));
		BASELINE_TIMES
				.put("PreparedStatement.setDouble()", new Double(0.00671));
		BASELINE_TIMES.put("PreparedStatement.setTime()", new Double(0.0642));
		BASELINE_TIMES.put("PreparedStatement.setTimestamp()", new Double(
				0.03184));
		BASELINE_TIMES.put("PreparedStatement.setDate()", new Double(0.12248));
		BASELINE_TIMES
				.put("PreparedStatement.setString()", new Double(0.01512));
		BASELINE_TIMES.put("PreparedStatement.setObject() on a string",
				new Double(0.01923));
		BASELINE_TIMES.put("single selects", new Double(46));
		BASELINE_TIMES.put("5 standalone queries", new Double(146));
		BASELINE_TIMES.put("total time all queries", new Double(190));
	}

	public MicroPerformanceRegressionTest(String name) {
		super(name);
	}

	/**
	 * Runs all test cases in this test suite
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		junit.textui.TestRunner.run(MicroPerformanceRegressionTest.class);
	}

	/**
	 * Tests result set accessors performance.
	 * 
	 * @throws Exception
	 *             if the performance of these methods does not meet
	 *             expectations.
	 */
	public void testResultSetAccessors() throws Exception {
		try {
			this.stmt.executeUpdate("DROP TABLE IF EXISTS marktest");
			this.stmt
					.executeUpdate("CREATE TABLE marktest(intField INT, floatField DOUBLE, timeField TIME, datetimeField DATETIME, stringField VARCHAR(64))");
			this.stmt
					.executeUpdate("INSERT INTO marktest VALUES (123456789, 12345.6789, NOW(), NOW(), 'abcdefghijklmnopqrstuvABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@')");

			this.rs = this.stmt
					.executeQuery("SELECT intField, floatField, timeField, datetimeField, stringField FROM marktest");

			this.rs.next();

			int numLoops = 100000;

			long start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getInt(1);
			}

			double getIntAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getInt()", getIntAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getDouble(2);
			}

			double getDoubleAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getDouble()", getDoubleAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getTime(3);
			}

			double getTimeAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getTime()", getTimeAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getTimestamp(4);
			}

			double getTimestampAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getTimestamp()", getTimestampAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getDate(4);
			}

			double getDateAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getDate()", getDateAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getString(5);
			}

			double getStringAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getString()", getStringAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				this.rs.getObject(5);
			}

			double getStringObjAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("ResultSet.getObject() on a string", getStringObjAvgMs);
		} finally {
			this.stmt.executeUpdate("DROP TABLE IF EXISTS marktest");
		}
	}

	public void testPreparedStatementTimes() throws Exception {
		try {
			this.stmt.executeUpdate("DROP TABLE IF EXISTS marktest");
			this.stmt
					.executeUpdate("CREATE TABLE marktest(intField INT, floatField DOUBLE, timeField TIME, datetimeField DATETIME, stringField VARCHAR(64))");
			this.stmt
					.executeUpdate("INSERT INTO marktest VALUES (123456789, 12345.6789, NOW(), NOW(), 'abcdefghijklmnopqrstuvABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@')");

			long start = System.currentTimeMillis();

			long blockStart = System.currentTimeMillis();
			long lastBlock = 0;

			int numLoops = 100000;

			int numPrepares = 100000;

			if (versionMeetsMinimum(4, 1)) {
				numPrepares = 10000; // we don't need to do so many for
				// server-side prep statements...
			}

			for (int i = 0; i < numPrepares; i++) {
				if (i % 1000 == 0) {

					long blockEnd = System.currentTimeMillis();

					long totalTime = blockEnd - blockStart;

					blockStart = blockEnd;

					StringBuffer messageBuf = new StringBuffer();

					messageBuf.append(i
							+ " prepares, the last 1000 prepares took "
							+ totalTime + " ms");

					if (lastBlock == 0) {
						lastBlock = totalTime;
						messageBuf.append(".");
					} else {
						double diff = (double) totalTime / (double) lastBlock;

						messageBuf.append(", difference is " + diff + " x");

						lastBlock = totalTime;
					}

					System.out.println(messageBuf.toString());

				}

				PreparedStatement pStmt = this.conn
						.prepareStatement("INSERT INTO test.marktest VALUES (?, ?, ?, ?, ?)");
				pStmt.close();
			}

			double getPrepareStmtAvgMs = (double) (System.currentTimeMillis() - start)
					/ numPrepares;

			// checkTime("Connection.prepareStatement()", getPrepareStmtAvgMs);

			PreparedStatement pStmt = this.conn
					.prepareStatement("INSERT INTO marktest VALUES (?, ?, ?, ?, ?)");

			System.out.println(pStmt.toString());

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				pStmt.setInt(1, 1);
			}

			System.out.println(pStmt.toString());

			double setIntAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setInt()", setIntAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				pStmt.setDouble(2, 1234567890.1234);
			}

			double setDoubleAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setDouble()", setDoubleAvgMs);

			start = System.currentTimeMillis();

			Time tm = new Time(start);

			for (int i = 0; i < numLoops; i++) {
				pStmt.setTime(3, tm);
			}

			double setTimeAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setTime()", setTimeAvgMs);

			start = System.currentTimeMillis();

			Timestamp ts = new Timestamp(start);

			for (int i = 0; i < numLoops; i++) {
				pStmt.setTimestamp(4, ts);
			}

			double setTimestampAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setTimestamp()", setTimestampAvgMs);

			start = System.currentTimeMillis();

			Date dt = new Date(start);

			for (int i = 0; i < numLoops; i++) {
				pStmt.setDate(4, dt);
			}

			double setDateAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setDate()", setDateAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				pStmt
						.setString(5,
								"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@");
			}

			double setStringAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setString()", setStringAvgMs);

			start = System.currentTimeMillis();

			for (int i = 0; i < numLoops; i++) {
				pStmt
						.setObject(5,
								"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@");
			}

			double setStringObjAvgMs = (double) (System.currentTimeMillis() - start)
					/ numLoops;

			checkTime("PreparedStatement.setObject() on a string",
					setStringObjAvgMs);

			start = System.currentTimeMillis();

		} finally {
			this.stmt.executeUpdate("DROP TABLE IF EXISTS marktest");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	public void setUp() throws Exception {
		super.setUp();

		System.out.println("Calculating performance scaling factor...");
		// Run this simple test to get some sort of performance scaling factor,
		// compared to
		// the development environment. This should help reduce false-positives
		// on this test.
		int numLoops = 10000;

		long start = System.currentTimeMillis();

		for (int j = 0; j < 2000; j++) {
			StringBuffer buf = new StringBuffer(numLoops);

			for (int i = 0; i < numLoops; i++) {
				buf.append('a');
			}
		}

		long elapsedTime = System.currentTimeMillis() - start;

		System.out.println("Elapsed time for factor: " + elapsedTime);

		this.scaleFactor = (double) elapsedTime
				/ (double) ORIGINAL_LOOP_TIME_MS;

		System.out
				.println("Performance scaling factor is: " + this.scaleFactor);
	}

	private void checkTime(String testType, double avgExecTimeMs)
			throws Exception {
		
		double adjustForVendor = 1.0D;

		if (isRunningOnJRockit()) {
			adjustForVendor = 4.0D;
		}

		Double baselineExecTimeMs = (Double) BASELINE_TIMES.get(testType);

		if (baselineExecTimeMs == null) {
			throw new Exception("No baseline time recorded for test '"
					+ testType + "'");
		}

		double acceptableTime = LEEWAY * baselineExecTimeMs.doubleValue()
				* this.scaleFactor * adjustForVendor;

		assertTrue("Average execution time of " + avgExecTimeMs
				+ " ms. exceeded baseline * leeway of " + acceptableTime
				+ " ms.", (avgExecTimeMs <= acceptableTime));
	}

	public void testBug6359() throws Exception {
		if (runLongTests()) {
			int numRows = 550000;
			int numSelects = 100000;

			try {
				this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug6359");
				this.stmt
						.executeUpdate("CREATE TABLE testBug6359 (pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1 INT, field2 INT, field3 INT, field4 INT, field5 INT, field6 INT, field7 INT, field8 INT, field9 INT,  INDEX (field1))");

				PreparedStatement pStmt = this.conn
						.prepareStatement("INSERT INTO testBug6359 (field1, field2, field3, field4, field5, field6, field7, field8, field9) VALUES (?, 1, 2, 3, 4, 5, 6, 7, 8)");

				logDebug("Loading " + numRows + " rows...");

				for (int i = 0; i < numRows; i++) {
					pStmt.setInt(1, i);
					pStmt.executeUpdate();

					if ((i % 10000) == 0) {
						logDebug(i + " rows loaded so far");
					}
				}

				logDebug("Finished loading rows");

				long begin = System.currentTimeMillis();

				long beginSingleQuery = System.currentTimeMillis();

				for (int i = 0; i < numSelects; i++) {
					this.rs = this.stmt
							.executeQuery("SELECT pk_field FROM testBug6359 WHERE field1 BETWEEN 1 AND 5");
				}

				long endSingleQuery = System.currentTimeMillis();

				double secondsSingleQuery = ((double) endSingleQuery - (double) beginSingleQuery) / 1000;

				logDebug("time to execute " + numSelects + " single queries: "
						+ secondsSingleQuery + " seconds");

				checkTime("single selects", secondsSingleQuery);

				PreparedStatement pStmt2 = this.conn
						.prepareStatement("SELECT field2, field3, field4, field5 FROM testBug6359 WHERE pk_field=?");

				long beginFiveQueries = System.currentTimeMillis();

				for (int i = 0; i < numSelects; i++) {

					for (int j = 0; j < 5; j++) {
						pStmt2.setInt(1, j);
						pStmt2.executeQuery();
					}
				}

				long endFiveQueries = System.currentTimeMillis();

				double secondsFiveQueries = ((double) endFiveQueries - (double) beginFiveQueries) / 1000;

				logDebug("time to execute " + numSelects
						+ " 5 standalone queries: " + secondsFiveQueries
						+ " seconds");

				checkTime("5 standalone queries", secondsFiveQueries);

				long end = System.currentTimeMillis();

				double seconds = ((double) end - (double) begin) / 1000;

				logDebug("time to execute " + numSelects + " selects: "
						+ seconds + " seconds");

				checkTime("total time all queries", seconds);
			} finally {
				this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug6359");
			}
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品久久不卡毛片| 国产精品影视在线| 国产精品小仙女| 欧美日韩aaaaaa| 国产精品系列在线| 美女免费视频一区| 欧美日韩一区二区三区四区五区 | 欧美日韩国产三级| 久久亚洲精精品中文字幕早川悠里| 亚洲女人的天堂| 国产91丝袜在线观看| 日韩欧美电影一二三| 亚洲一区二区在线免费看| 成人性生交大片免费看中文网站| 欧美成人午夜电影| 亚洲不卡一区二区三区| 欧美三级资源在线| 亚洲区小说区图片区qvod| 国产91精品免费| 久久蜜桃av一区精品变态类天堂| 免费观看在线综合色| 欧美高清性hdvideosex| 亚洲国产精品综合小说图片区| 99re这里只有精品首页| 中文字幕不卡在线播放| 从欧美一区二区三区| 久久久久亚洲蜜桃| 国产麻豆成人传媒免费观看| 精品国产区一区| 狠狠色丁香婷综合久久| 欧美不卡一区二区三区| 久久99精品国产麻豆婷婷洗澡| 欧美一区二区在线视频| 久久机这里只有精品| 日韩精品自拍偷拍| 国产乱码一区二区三区| 国产亚洲欧美日韩俺去了| 国产精品一色哟哟哟| 国产欧美1区2区3区| 成人免费高清在线| 综合久久综合久久| 欧美影视一区在线| 男男gaygay亚洲| 2021久久国产精品不只是精品| 韩国av一区二区| 国产精品国产三级国产普通话三级 | 色欧美片视频在线观看在线视频| 最近日韩中文字幕| 色视频成人在线观看免| 亚洲综合在线五月| 日韩视频免费观看高清完整版| 精品亚洲成a人在线观看 | 高清国产一区二区| 亚洲免费观看高清完整| 欧美性猛交xxxxxx富婆| 男男成人高潮片免费网站| 久久久久九九视频| 一本色道久久综合亚洲aⅴ蜜桃| 一区二区三区蜜桃| 精品欧美黑人一区二区三区| 丰满亚洲少妇av| 亚洲午夜久久久久久久久久久| 日韩一区二区三区视频在线| 精一区二区三区| 日韩理论在线观看| 欧美一区二区三区在线视频| 成人ar影院免费观看视频| 婷婷成人综合网| 日本一二三不卡| 欧美乱妇20p| 成人黄页在线观看| 天天操天天综合网| 国产精品二三区| 日韩欧美精品三级| 白白色亚洲国产精品| 日本伊人精品一区二区三区观看方式 | 国产伦精品一区二区三区免费迷 | 韩国av一区二区| 亚洲自拍与偷拍| 亚洲国产精品成人久久综合一区| 欧美午夜影院一区| 成人v精品蜜桃久久一区| 青青草原综合久久大伊人精品优势| 国产精品第四页| 久久久www成人免费无遮挡大片| 欧美在线不卡视频| 成人国产精品免费网站| 免费成人在线视频观看| 亚洲国产成人av好男人在线观看| 欧美国产一区二区在线观看| 日韩小视频在线观看专区| 日本久久电影网| 夫妻av一区二区| 国内精品伊人久久久久av一坑| 亚洲成人黄色影院| 亚洲精品高清在线| 亚洲天堂精品在线观看| 亚洲国产成人私人影院tom| 日韩一级大片在线| 欧美日韩国产一级二级| 色综合天天狠狠| 9l国产精品久久久久麻豆| 国产成人综合亚洲91猫咪| 麻豆国产91在线播放| 日本不卡不码高清免费观看| 亚洲成人一区在线| 一区二区理论电影在线观看| 国产精品久久毛片a| 欧美激情一区二区三区在线| 久久九九99视频| 久久综合色婷婷| 久久九九久久九九| 国产欧美一区视频| 国产午夜精品一区二区三区四区| 久久综合九色综合欧美98| www国产亚洲精品久久麻豆| 久久人人爽人人爽| 久久精品欧美日韩| 中文字幕欧美国产| 国产精品女人毛片| 亚洲欧美日韩系列| 亚洲成人黄色小说| 久久精品国产亚洲aⅴ| 久久99精品久久久久久国产越南| 美女高潮久久久| 精品一区二区三区不卡 | 欧美经典一区二区三区| 欧美国产精品劲爆| 亚洲婷婷在线视频| 亚洲一区二区三区爽爽爽爽爽| 亚洲第一成年网| 久久99精品国产91久久来源| 韩国三级电影一区二区| 成人午夜av在线| 欧美影视一区在线| 欧美va亚洲va在线观看蝴蝶网| 国产亚洲va综合人人澡精品| 亚洲视频免费观看| 无码av中文一区二区三区桃花岛| 日本三级亚洲精品| 夫妻av一区二区| 欧美日韩亚洲综合一区二区三区 | 亚洲女同一区二区| 美女在线视频一区| 高潮精品一区videoshd| 欧美性xxxxx极品少妇| 日韩精品一区二| 久久精品一区四区| 亚洲高清在线视频| 国产成人午夜99999| 在线观看日产精品| 久久久久久久久久久久久夜| 尤物在线观看一区| 国产综合成人久久大片91| 99这里只有久久精品视频| 欧美人伦禁忌dvd放荡欲情| 久久伊人蜜桃av一区二区| 亚洲人成网站在线| 精品亚洲成a人在线观看| 欧美艳星brazzers| 久久久久久久综合日本| 亚洲一区二区av电影| 国产精品中文字幕欧美| 欧美性高清videossexo| 久久久www免费人成精品| 午夜a成v人精品| 91免费观看视频在线| 久久综合色8888| 亚洲444eee在线观看| 91在线观看视频| 久久久久久久久蜜桃| 免费在线观看不卡| 在线亚洲人成电影网站色www| 国产亚洲美州欧州综合国| 美脚の诱脚舐め脚责91| 欧美日韩三级视频| 亚洲天堂免费看| 成人精品免费视频| 久久久久久久久久久电影| 午夜影院在线观看欧美| 色婷婷精品久久二区二区蜜臀av| 国产亚洲欧美中文| 国产一区二区视频在线| 日韩一区二区三区免费看| 亚洲高清一区二区三区| 色婷婷精品久久二区二区蜜臂av | 亚洲国产精品高清| 韩国精品一区二区| 精品999久久久| 精品一区二区三区蜜桃| 日韩欧美一区二区久久婷婷| 日本在线不卡视频| 日韩一区二区免费电影| 青青草精品视频| 日韩精品一区二区三区中文不卡 | 国产亚洲精品bt天堂精选| 国产一区二区美女| 精品国产露脸精彩对白| 久久99精品久久久久久久久久久久| 日韩免费视频一区二区|