⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sailbmtest.java

📁 这是外国一个开源推理机
💻 JAVA
字号:
/*  Sesame - Storage and Querying architecture for RDF and RDF Schema *  Copyright (C) 2001-2005 Aduna * *  Contact:  *  	Aduna *  	Prinses Julianaplein 14 b *  	3817 CS Amersfoort *  	The Netherlands *  	tel. +33 (0)33 465 99 87 *  	fax. +33 (0)33 465 99 87 * *  	http://aduna.biz/ *  	http://www.openrdf.org/ *   *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public *  License as published by the Free Software Foundation; either *  version 2.1 of the License, or (at your option) any later version. * *  This library 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 *  Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.openrdf.sesame.sail.test.benchmark;import java.io.FileNotFoundException;import java.io.IOException;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.ListIterator;import java.util.Map;import java.util.Properties;import java.util.StringTokenizer;import org.openrdf.sesame.sail.Sail;import org.openrdf.sesame.sail.SailInitializationException;import org.openrdf.sesame.sail.test.benchmark.pools.SailPool;import org.openrdf.sesame.sail.test.benchmark.tests.Initialize;import org.openrdf.sesame.sail.test.benchmark.tests.SailBMTestA;import org.openrdf.sesame.sail.test.benchmark.tests.ShutDown;import org.openrdf.sesame.sail.test.benchmark.util.BMUtil;/** * Tests performance of implementations of org.openrdf.sesame.sail.Sail. * * @author Peter van 't Hof * @version %I%, %G% */public class SailBMTest {/*----------+| Variables |+----------*/	// Sail to test performance of.	protected Sail _sail;	// Test configuration.	protected Properties _properties;		// Maximum time in millisseconds.	protected final static int _maxTime = 54000000;	// List containing individual tests.	protected List _tests;/*-------------+| Constructors |+-------------*/	/**	 * Creates a new benchmark test which tests implementations of	 * org.openrdf.sesame.sail.Sail.	 *	 * @param sail Sail to test.	 * @param properties Configuration file.	 */		public SailBMTest(Sail sail, Properties properties) {		_sail = sail;		_properties = properties;		_tests = new ArrayList();	}/*--------+| Methods |+--------*/	/**	 * Tests performance of Sail.	 *	 * @throws IOException If an I/O error occurs.	 * @throws SailInitializationException If the Sail could not be initialized.	 */ 	public void test()		throws Exception {		_status("Testing " + _properties.getProperty("description") + "...");		// Get configuration parameters.		Map parameters = new HashMap();		StringTokenizer tokenizer = 			new StringTokenizer(_getProperty("configKeys"), ",");				while (tokenizer.hasMoreTokens()) {			String configKey = tokenizer.nextToken().trim();			parameters.put(configKey, _getProperty(configKey));		}				_tests.add(new Initialize(_sail, parameters));		_createTests();		_tests.add(new ShutDown(_sail));		_executeTests();		_status("Sail tested.");	}	protected void _createTests() {}	protected void _executeTests() 		throws Exception {			boolean testsDone = false;		boolean poolFilled = false;						while(!testsDone) {			ListIterator j = _tests.listIterator();									if (!j.hasNext()) {				testsDone = true;			}			else {				while(j.hasNext()) {					SailBMTestA test = (SailBMTestA)j.next();					// Skip ShutDown until no more tests left.					if (!j.hasNext() && _tests.size() > 1) {						break;					}					if (test.needsPool() && !poolFilled) {						_fillPool();												poolFilled = true;					}					test.test();										if (test.testDone()) {						System.out.println();						System.out.println(test.toString());						// Remove test from list.						j.remove();					}				}			}		}		System.out.println();	}	protected void _fillPool()		throws IOException, ClassNotFoundException {		String file = _getProperty("pool");		SailPool pool = _getPool();				try {			System.out.println();			pool.load(file);		} 		catch (FileNotFoundException e) {			pool.initialize();			pool.save(file);		}	}	protected SailPool _getPool() {		return new SailPool(_sail);	}	protected String _getProperty(String name) {		String value = _properties.getProperty(name);		if (value == null) {			BMUtil.exit(name + " missing.");		}		return value;	}	// Checks whether benchmark test with name name should be executed.	protected boolean _executeTest(String name) {		String value = _properties.getProperty(name);		if (value != null && value.equals("yes")) {			// Execute test.			return true;		}		return false;	}	protected void _status(String status) {		BMUtil.status(status);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -