📄 performancetest.java
字号:
package org.redsoft.forum.dao;import junit.framework.TestCase;import org.redsoft.forum.dao.mysql.ThreadDAOmySql;import org.redsoft.forum.dao.jdo.ThreadDAOJDO;import org.redsoft.forum.dao.jdo.LiberatorDAOFactory;import org.redsoft.forum.exception.DAOException;/** * Created by IntelliJ IDEA. * User: hua9664 * Date: 24-Feb-2004 * Time: 2:32:04 PM * To change this template use Options | File Templates. */public class PerformanceTest extends TestCase { private static int category = 100; /** * Start the tests. * * @param args the arguments. Not used */ public static void main(String args[]) { new PerformanceTest().testInsertPerformance(); } public void testInsertPerformance() { try { ThreadDAOmySql jdbcDAO = new ThreadDAOmySql(); long startTime = System.currentTimeMillis(); for (int index = 0; index < 1000; index++) { long current = System.currentTimeMillis(); org.redsoft.forum.dao.Thread thread = new org.redsoft.forum.dao.Thread( "my first", "hello I can't have it. \"world\",hello world", "charles", current, -1, category, 1, 0, 1234, true); thread = jdbcDAO.addThread(thread); } long endTime = System.currentTimeMillis(); System.out.println( "Insert 1000 records" ); System.out.println( "JDBC: Total = " + (endTime - startTime) + "ms" ); startTime = System.currentTimeMillis(); ThreadDAOJDO jdoDAO = (ThreadDAOJDO) new LiberatorDAOFactory().getThreadDAO(); for (int index = 0; index < 1000; index++) { long current = System.currentTimeMillis(); org.redsoft.forum.dao.Thread thread = new org.redsoft.forum.dao.Thread( "my first", "hello I can't have it. \"world\",hello world", "charles", current, -1, category, 1, 0, 1234, true); thread = jdoDAO.addThread(thread); } endTime = System.currentTimeMillis(); System.out.println( "JDO : Total = " + (endTime - startTime) + "ms" ); } catch (final DAOException e) { fail(e.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -