Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Tentackle - https://tentackle.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.tentackle.dbms;
import org.tentackle.common.Compare;
import org.tentackle.log.Logger;
import org.tentackle.log.Logger.Level;
import org.tentackle.misc.FormatHelper;
import org.tentackle.misc.TimeKeeper;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Statement statistics collector.
*
* @author harald
*/
public class StatementStatistics implements Comparable {
private static final Logger LOGGER = Logger.get(StatementStatistics.class);
private static final String LOG_TAG = " >SQL-Stats: ";
// instance counter
private static final AtomicInteger INSTANCE_COUNT = new AtomicInteger();
// statistics collector
private static final Map STAT_MAP = new HashMap<>();
// the time statistics began in epochal milliseconds.
private static long since;
/**
* If true the statistics are per statement and parameters, else only per statement.
*/
private static boolean withParameters;
/**
* Sets whether statistics should be separated according to the statement parameters.
*
* @param withParams true if with parameter stats
*/
public static void setWithParameters(boolean withParams) {
withParameters = withParams;
}
/**
* Returns whether statistics should be separated according to the statement parameters.
*
* @return rue if with parameter stats
*/
public static boolean isWithParameters() {
return withParameters;
}
/**
* Collects the statistics from a statement history.
*
* @param history the history to collect
*/
public static synchronized void collect(StatementHistory history) {
List