[hibernate-commits] Hibernate SVN: r20205 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: engine and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Aug 20 07:01:04 EDT 2010


Author: hardy.ferentschik
Date: 2010-08-20 07:01:03 -0400 (Fri, 20 Aug 2010)
New Revision: 20205

Modified:
   search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java
   search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java
   search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
   search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
   search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java
Log:
HSEARCH-278 Switched to nano second resolution for timings

Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java	2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java	2010-08-20 11:01:03 UTC (rev 20205)
@@ -1,26 +1,25 @@
-/* $Id$
- * 
+/*
  * Hibernate, Relational Persistence for Idiomatic Java
- * 
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat, Inc.
- * 
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- * 
- * 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 Lesser General Public License
- * for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
+ *
+ *  Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ *  indicated by the @author tags or express copyright attribution
+ *  statements applied by the authors.  All third-party contributions are
+ *  distributed under license by Red Hat, Inc.
+ *
+ *  This copyrighted material is made available to anyone wishing to use, modify,
+ *  copy, or redistribute it subject to the terms and conditions of the GNU
+ *  Lesser General Public License, as published by the Free Software Foundation.
+ *
+ *  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 Lesser General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this distribution; if not, write to:
+ *  Free Software Foundation, Inc.
+ *  51 Franklin Street, Fifth Floor
+ *  Boston, MA  02110-1301  USA
  */
 package org.hibernate.search;
 
@@ -29,6 +28,10 @@
  * @author Hardy Ferentschik
  */
 public final class Environment {
+	
+	private Environment() {
+	}
+
 	/**
 	 * Enable listeners auto registration in Hibernate Annotations and EntityManager. Default to true.
 	 */

Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java	2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java	2010-08-20 11:01:03 UTC (rev 20205)
@@ -46,11 +46,11 @@
 	public final Object load(EntityInfo entityInfo) {
 		long startTime = 0;
 		if ( takeTimings ) {
-			startTime = System.currentTimeMillis();
+			startTime = System.nanoTime();
 		}
 		Object loadedObject = executeLoad( entityInfo );
 		if ( takeTimings ) {
-			statisticsImplementor.objectLoadExecuted( 1, System.currentTimeMillis() - startTime );
+			statisticsImplementor.objectLoadExecuted( 1, System.nanoTime() - startTime );
 		}
 		return loadedObject;
 	}
@@ -60,11 +60,11 @@
 	public List load(EntityInfo... entityInfos) {
 		long startTime = 0;
 		if ( takeTimings ) {
-			startTime = System.currentTimeMillis();
+			startTime = System.nanoTime();
 		}
 		List loadedObjects = executeLoad( entityInfos );
 		if ( takeTimings ) {
-			statisticsImplementor.objectLoadExecuted( loadedObjects.size(), System.currentTimeMillis() - startTime );
+			statisticsImplementor.objectLoadExecuted( loadedObjects.size(), System.nanoTime() - startTime );
 		}
 		return loadedObjects;
 	}

Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java	2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java	2010-08-20 11:01:03 UTC (rev 20205)
@@ -402,7 +402,7 @@
 		boolean stats = searchFactoryImplementor.getStatistics().isStatisticsEnabled();
 		long startTime = 0;
 		if ( stats ) {
-			startTime = System.currentTimeMillis();
+			startTime = System.nanoTime();
 		}
 
 		if ( n == null ) { // try to make sure that we get the right amount of top docs
@@ -414,7 +414,7 @@
 		resultSize = queryHits.totalHits;
 
 		if ( stats ) {
-			searchFactoryImplementor.getStatisticsImplementor().searchExecuted( query.toString(), System.currentTimeMillis() - startTime );
+			searchFactoryImplementor.getStatisticsImplementor().searchExecuted( query.toString(), System.nanoTime() - startTime );
 		}
 
 		return queryHits;

Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java	2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java	2010-08-20 11:01:03 UTC (rev 20205)
@@ -47,17 +47,17 @@
 	long getSearchQueryExecutionCount();
 
 	/**
-	 * Get the total search time in milliseconds.
+	 * Get the total search time in nanoseconds.
 	 */
 	long getSearchQueryTotalTime();
 
 	/**
-	 * Get the time in milliseconds of the slowest search.
+	 * Get the time in nanoseconds of the slowest search.
 	 */
 	long getSearchQueryExecutionMaxTime();
 
 	/**
-	 * Get the average search time in milliseconds.
+	 * Get the average search time in nanoseconds.
 	 */
 	long getSearchQueryExecutionAvgTime();
 
@@ -67,17 +67,17 @@
 	String getSearchQueryExecutionMaxTimeQueryString();
 
 	/**
-	 * Get the total object loading in milliseconds.
+	 * Get the total object loading in nanoseconds.
 	 */
 	long getObjectLoadingTotalTime();
 
 	/**
-	 * Get the time in milliseconds for the slowest object load.
+	 * Get the time in nanoseconds for the slowest object load.
 	 */
 	long getObjectLoadingExecutionMaxTime();
 
 	/**
-	 * Get the average object loading time in milliseconds.
+	 * Get the average object loading time in nanoseconds.
 	 */
 	long getObjectLoadingExecutionAvgTime();
 

Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java	2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java	2010-08-20 11:01:03 UTC (rev 20205)
@@ -26,10 +26,24 @@
 package org.hibernate.search.stat;
 
 /**
+ * Statistics SPI for the Search. This is essentially the "statistic collector" API.
+ * 
  * @author Hardy Ferentschik
  */
 public interface StatisticsImplementor {
+	/**
+	 * Callback for number of object loaded from the db.
+	 * 
+	 * @param numberOfObjectsLoaded  Number of objects loaded
+	 * @param time time in nanoseconds to load the objects
+	 */
 	void objectLoadExecuted(long numberOfObjectsLoaded, long time);
 	
+	/**
+	 * Callback for an executed Lucene search.
+	 * 
+	 * @param searchString executed query string
+	 * @param time time in nanoseconds to execute the search
+	 */	
 	void searchExecuted(String searchString, long time);
 }



More information about the hibernate-commits mailing list