/** * Tests the {@link PerformanceLevel#forDuration(long, TimeUnit)} method. */ @Test public void testForDuration() { assertSame(SLOW, forDuration(500, TimeUnit.MILLISECONDS)); assertSame(SLOWER, forDuration(2, TimeUnit.SECONDS)); assertSame(SLOWEST, forDuration(6, TimeUnit.SECONDS)); assertSame(PERFORMANCE, forDuration(50, TimeUnit.MILLISECONDS)); } }
/** * Tests modifying the configuration. */ @Test public void testSetMinDuration() { try { SLOW.setMinDuration(2, TimeUnit.SECONDS); assertEquals(0, PERFORMANCE.getMinDuration(TimeUnit.SECONDS)); assertEquals(2, SLOW .getMinDuration(TimeUnit.SECONDS)); assertEquals(2, SLOWER .getMinDuration(TimeUnit.SECONDS)); assertEquals(5, SLOWEST .getMinDuration(TimeUnit.SECONDS)); SLOWEST.setMinDuration(1, TimeUnit.SECONDS); assertEquals(0, PERFORMANCE.getMinDuration(TimeUnit.SECONDS)); assertEquals(1, SLOW .getMinDuration(TimeUnit.SECONDS)); assertEquals(1, SLOWER .getMinDuration(TimeUnit.SECONDS)); assertEquals(1, SLOWEST .getMinDuration(TimeUnit.SECONDS)); PERFORMANCE.setMinDuration(6, TimeUnit.SECONDS); assertEquals(0, PERFORMANCE.getMinDuration(TimeUnit.SECONDS)); assertEquals(6, SLOW .getMinDuration(TimeUnit.SECONDS)); assertEquals(6, SLOWER .getMinDuration(TimeUnit.SECONDS)); assertEquals(6, SLOWEST .getMinDuration(TimeUnit.SECONDS)); } finally { SLOW .setMinDuration(100, TimeUnit.MILLISECONDS); SLOWER .setMinDuration(1, TimeUnit.SECONDS); SLOWEST.setMinDuration(5, TimeUnit.SECONDS); } }
ensurePositive("duration", duration); duration = unit.toNanos(duration); final int value = intValue(); synchronized (PerformanceLevel.class) {
/** * Ensures that the duration are conform to the documentation. */ @Test public void testGetMinDuration() { assertEquals(0, PERFORMANCE.getMinDuration(TimeUnit.NANOSECONDS)); assertEquals(100, SLOW .getMinDuration(TimeUnit.MILLISECONDS)); assertEquals(1, SLOWER .getMinDuration(TimeUnit.SECONDS)); assertEquals(5, SLOWEST .getMinDuration(TimeUnit.SECONDS)); }
caller = "create".concat(type.getSimpleName()); final PerformanceLevel level = PerformanceLevel.forDuration(time, TimeUnit.NANOSECONDS); final Double duration = time / (double) StandardDateFormat.NANOS_PER_SECOND; final Messages resources = Messages.getResources(null);
ensurePositive("duration", duration); duration = unit.toNanos(duration); final int value = intValue(); synchronized (PerformanceLevel.class) {
caller = "create".concat(type.getSimpleName()); final PerformanceLevel level = PerformanceLevel.forDuration(time, TimeUnit.NANOSECONDS); final Double duration = time / (double) StandardDateFormat.NANOS_PER_SECOND; final Messages resources = Messages.getResources(null);
/** * Processes to the creation of the EPSG database using the SQL scripts from the given provider. * * @param scriptProvider user-provided scripts, or {@code null} for automatic lookup. * @param locale the locale for information or warning messages, if any. * @throws FileNotFoundException if a SQL script has not been found. * @throws IOException if another error occurred while reading an input. * @throws SQLException if an error occurred while executing a SQL statement. */ public void run(InstallationResources scriptProvider, final Locale locale) throws SQLException, IOException { long time = System.nanoTime(); InstallationScriptProvider.log(Messages.getResources(locale).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, EPSG, SQLUtilities.getSimplifiedURL(getConnection().getMetaData()))); if (scriptProvider == null) { scriptProvider = lookupProvider(locale); } final String[] scripts = scriptProvider.getResourceNames(EPSG); int numRows = 0; for (int i=0; i<scripts.length; i++) { try (BufferedReader in = scriptProvider.openScript(EPSG, i)) { numRows += run(scripts[i], in); } } time = System.nanoTime() - time; InstallationScriptProvider.log(Messages.getResources(locale).getLogRecord( PerformanceLevel.forDuration(time, TimeUnit.NANOSECONDS), Messages.Keys.InsertDuration_2, numRows, time / (float) StandardDateFormat.NANOS_PER_SECOND)); }
/** * Processes to the creation of the EPSG database using the SQL scripts from the given provider. * * @param scriptProvider user-provided scripts, or {@code null} for automatic lookup. * @param locale the locale for information or warning messages, if any. * @throws FileNotFoundException if a SQL script has not been found. * @throws IOException if another error occurred while reading an input. * @throws SQLException if an error occurred while executing a SQL statement. */ public void run(InstallationResources scriptProvider, final Locale locale) throws SQLException, IOException { long time = System.nanoTime(); InstallationScriptProvider.log(Messages.getResources(locale).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, EPSG, SQLUtilities.getSimplifiedURL(getConnection().getMetaData()))); if (scriptProvider == null) { scriptProvider = lookupProvider(locale); } final String[] scripts = scriptProvider.getResourceNames(EPSG); int numRows = 0; for (int i=0; i<scripts.length; i++) { try (BufferedReader in = scriptProvider.openScript(EPSG, i)) { numRows += run(scripts[i], in); } } time = System.nanoTime() - time; InstallationScriptProvider.log(Messages.getResources(locale).getLogRecord( PerformanceLevel.forDuration(time, TimeUnit.NANOSECONDS), Messages.Keys.InsertDuration_2, numRows, time / (float) StandardDateFormat.NANOS_PER_SECOND)); }