Example usage for java.util.concurrent TimeUnit MICROSECONDS

List of usage examples for java.util.concurrent TimeUnit MICROSECONDS

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MICROSECONDS.

Prototype

TimeUnit MICROSECONDS

To view the source code for java.util.concurrent TimeUnit MICROSECONDS.

Click Source Link

Document

Time unit representing one thousandth of a millisecond.

Usage

From source file:io.druid.benchmark.indexing.IndexMergeBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/*from   w ww .  j  a v  a 2s . c o  m*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void mergeV9(Blackhole blackhole) throws Exception {
    File tmpFile = File.createTempFile("IndexMergeBenchmark-MERGEDFILE-V9-" + System.currentTimeMillis(),
            ".TEMPFILE");
    tmpFile.delete();
    tmpFile.mkdirs();
    try {
        log.info(
                tmpFile.getAbsolutePath() + " isFile: " + tmpFile.isFile() + " isDir:" + tmpFile.isDirectory());

        File mergedFile = INDEX_MERGER_V9.mergeQueryableIndex(indexesToMerge, rollup, schemaInfo.getAggsArray(),
                tmpFile, new IndexSpec());

        blackhole.consume(mergedFile);
    } finally {
        tmpFile.delete();

    }

}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
 * Input Testing://w  w  w.  j a v a 2 s .com
 *
 * TimeUnit parsing requires the String value be in UpperCase.
 * Ensure we can handle when the user doesn't know this.
 *
 * Same test as 'testConfigLoadingValidConfig' but checking that
 * the timeunit field is not case sensitive.
 * i.e. the toUpper is being correctly applied.
 */
public void testConfigLoadingValidConfigStrangeTimeUnit() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    long DELAY = 10;

    xmlconfig.addProperty("delay", DELAY);
    xmlconfig.addProperty("timeunit", "MiCrOsEcOnDs");

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);

    try {
        config.setConfiguration("", composite);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }

    assertEquals("Delay not correctly returned.", DELAY, config.getDelay());
    assertEquals("TimeUnit not correctly returned.", TimeUnit.MICROSECONDS.toString(),
            String.valueOf(config.getTimeUnit()));

}

From source file:org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics.java

private void appendMetrics(final Collection<? extends Metrics> metrics, final StringBuilder sb,
        final int indent) {
    // Append each StepMetric's row. indexToLabelMap values are ordered by index.
    for (Metrics m : metrics) {
        String rowName = m.getName();

        // Handle indentation
        for (int ii = 0; ii < indent; ii++) {
            rowName = "  " + rowName;
        }//from   ww  w .  j  av a 2  s. c  om
        // Abbreviate if necessary
        rowName = StringUtils.abbreviate(rowName, 50);

        // Grab the values
        final Long itemCount = m.getCount(ELEMENT_COUNT_ID);
        final Long traverserCount = m.getCount(TRAVERSER_COUNT_ID);
        Double percentDur = (Double) m.getAnnotation(PERCENT_DURATION_KEY);

        // Build the row string

        sb.append(String.format("%n%-50s", rowName));

        if (itemCount != null) {
            sb.append(String.format(" %21d", itemCount));
        } else {
            sb.append(String.format(" %21s", ""));
        }

        if (traverserCount != null) {
            sb.append(String.format(" %11d", traverserCount));
        } else {
            sb.append(String.format(" %11s", ""));
        }

        sb.append(String.format(" %15.3f", m.getDuration(TimeUnit.MICROSECONDS) / 1000.0));

        if (percentDur != null) {
            sb.append(String.format(" %8.2f", percentDur));
        }

        appendMetrics(m.getNested(), sb, indent + 1);
    }
}

From source file:org.apache.druid.benchmark.indexing.IndexPersistBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)//from ww w .  j ava2 s  .c o  m
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void persistV9(Blackhole blackhole) throws Exception {
    File tmpDir = Files.createTempDir();
    log.info("Using temp dir: " + tmpDir.getAbsolutePath());
    try {
        File indexFile = INDEX_MERGER_V9.persist(incIndex, tmpDir, new IndexSpec(), null);

        blackhole.consume(indexFile);

    } finally {
        FileUtils.deleteDirectory(tmpDir);
    }
}

From source file:com.endgame.binarypig.loaders.AbstractFileDroppingLoader.java

public void dumpStats() {
    System.err.println("workDir     = " + workingDir);
    System.err.println("dataDir     = " + dataDir);
    System.err.println("useDevShm     = " + useDevShm);
    System.err.println("numRecords     = " + numRecords);

    long usec = totalOverhead.elapsedTime(TimeUnit.MICROSECONDS);
    dumpStat("copyOverhead", copyOverhead, usec, numRecords);
    dumpStat("deleteOverhead", deleteOverhead, usec, numRecords);
    dumpStat("execOverhead", execOverhead, usec, numRecords);
    dumpStat("tupleCreationOverhead", tupleCreationOverhead, usec, numRecords);
    dumpStat("totalOverhead", totalOverhead, usec, numRecords);
}

From source file:com.amazonaws.services.cloudtrail.processinglibrary.AWSCloudTrailProcessingExecutor.java

/**
 * Start processing AWS CloudTrail logs.
 *//*w w  w.  j  a va 2s  . c o  m*/
public void start() {
    logger.info("Started AWSCloudTrailProcessingLibrary.");
    this.ValidateBeforeStart();
    scheduledThreadPool.scheduleAtFixedRate(new ScheduledJob(this.readerFactory), 0L, EXECUTION_DELAY,
            TimeUnit.MICROSECONDS);
}

From source file:com.jbombardier.reports.ReportGenerator.java

private static void buildTestsTable(List<TransactionResult> transactionResults, TimeUnit reportTimeUnits,
        HTMLBuilder2.Element testsDiv) {
    HTMLBuilder2.TableElement testsTable = testsDiv.table();

    testsTable.addClass("table");
    testsTable.addClass("table-striped");
    testsTable.addClass("table-header-rotated");

    String timeUnitDescription;//  w w  w. ja v a2s.  c o m
    if (reportTimeUnits == TimeUnit.NANOSECONDS) {
        timeUnitDescription = "(ns)";
    } else if (reportTimeUnits == TimeUnit.MICROSECONDS) {
        timeUnitDescription = "(s)";
    } else if (reportTimeUnits == TimeUnit.MILLISECONDS) {
        timeUnitDescription = "(ms)";
    } else {
        timeUnitDescription = "(s)";
    }

    HTMLBuilder2.THeadRow headerRow = testsTable.getThead().headerRow();

    headerRow.cell("Test name").addClass("rotate-45");
    headerRow.cell("Transaction").addClass("rotate-45");
    headerRow.cell("Total transaction count").addClass("rotate-45");

    headerRow.cell("Agents").addClass("rotate-45");
    headerRow.cell("Threads").addClass("rotate-45");
    //        headerRow.cell("Sample Time") .addClass("rotate-45");

    headerRow.cell("Successful transactions").addClass("rotate-45");
    headerRow.cell("Unsuccessful transactions").addClass("rotate-45");

    headerRow.cell("Mean duration " + timeUnitDescription).addClass("rotate-45");
    headerRow.cell("SLA").addClass("rotate-45");
    headerRow.cell("Mean TPS").addClass("rotate-45");
    headerRow.cell("Target TPS").addClass("rotate-45");
    headerRow.cell("Maximum TPS").addClass("rotate-45");

    headerRow.cell("Abs dev").addClass("rotate-45");
    headerRow.cell("%").addClass("rotate-45");
    headerRow.cell("stdevp").addClass("rotate-45");
    headerRow.cell("TP90").addClass("rotate-45");
    headerRow.cell("TP99").addClass("rotate-45");
    headerRow.cell("Median").addClass("rotate-45");
    headerRow.cell("Fastest").addClass("rotate-45");
    headerRow.cell("Slowest").addClass("rotate-45");

    headerRow.cell("Unsuccessful mean duration " + timeUnitDescription).addClass("rotate-45");
    headerRow.cell("Unsuccessful Mean TPS").addClass("rotate-45");

    for (TransactionResult transactionResult : transactionResults) {

        HTMLBuilder2.RowElement row = testsTable.row();

        row.cell(transactionResult.getTestName());
        row.cell(transactionResult.getTransactionName());
        row.cell(format(transactionResult.getTotalTransactionCount()));

        row.cell(format(transactionResult.getAgents()));
        row.cell(format(transactionResult.getThreads()));
        //            row.cell(TimeUtils.formatIntervalMilliseconds(transactionResult.getSampleTime()));

        row.cell(format(transactionResult.getSuccessfulTransactionCount()));
        row.cell(format(transactionResult.getUnsuccessfulTransactionCount()));

        row.cell(formatTime(transactionResult.getSuccessfulTransactionMeanDuration(), reportTimeUnits));
        row.cell(formatTime(transactionResult.getSla(), reportTimeUnits));
        row.cell(format(transactionResult.getSuccessfulTransactionMeanTransactionsPerSecond()));
        row.cell(format(transactionResult.getSuccessfulTransactionMeanTransactionsPerSecondTarget()));
        row.cell(format(transactionResult.getSuccessfulMaximumTransactionsPerSecond()));

        row.cell(formatTime(transactionResult.getSuccessfulAbsoluteDeviation(), reportTimeUnits));
        row.cell(format(transactionResult.getSuccessfulAbsoluteDeviationAsPercentage()));
        row.cell(formatTime(transactionResult.getSuccessfulStandardDeviation(), reportTimeUnits));
        row.cell(formatTime(transactionResult.getSuccessfulPercentiles()[90], reportTimeUnits));
        row.cell(formatTime(transactionResult.getSuccessfulPercentiles()[99], reportTimeUnits));
        row.cell(formatTime(transactionResult.getSuccessfulMedian(), reportTimeUnits));
        row.cell(formatTime(transactionResult.getSuccessfulFastestResult(), reportTimeUnits));
        row.cell(formatTime(transactionResult.getSuccessfulSlowestResult(), reportTimeUnits));

        row.cell(formatTime(transactionResult.getUnsuccessfulTransactionMeanDuration(), reportTimeUnits));
        row.cell(format(transactionResult.getUnsuccessfulTransactionMeanTransactionsPerSecond()));
    }
}

From source file:com.hoccer.api.RESTfulApiTest.java

private HttpResponse receiveOneToOne(String client) throws IOException, ClientProtocolException {
    HttpGet receive = new HttpGet(client + "/action/one-to-one");
    HttpResponse response;/*from   w  w  w .j av a  2s  .c om*/
    response = mHttpClient.execute(receive);
    mHttpClient.getConnectionManager().closeIdleConnections(1, TimeUnit.MICROSECONDS);

    return response;
}

From source file:org.apache.druid.benchmark.indexing.IndexMergeBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)//  ww  w. j  a v  a2  s . c  o m
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void mergeV9(Blackhole blackhole) throws Exception {
    File tmpFile = File.createTempFile("IndexMergeBenchmark-MERGEDFILE-V9-" + System.currentTimeMillis(),
            ".TEMPFILE");
    tmpFile.delete();
    tmpFile.mkdirs();
    try {
        log.info(
                tmpFile.getAbsolutePath() + " isFile: " + tmpFile.isFile() + " isDir:" + tmpFile.isDirectory());

        File mergedFile = INDEX_MERGER_V9.mergeQueryableIndex(indexesToMerge, rollup, schemaInfo.getAggsArray(),
                tmpFile, new IndexSpec(), null);

        blackhole.consume(mergedFile);
    } finally {
        tmpFile.delete();

    }

}

From source file:org.apache.nifi.processors.ISPEnrichIP.java

@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    FlowFile flowFile = session.get();//from   w  w  w.  j a  va  2 s .  co m
    if (flowFile == null) {
        return;
    }

    final DatabaseReader dbReader = databaseReaderRef.get();
    final String ipAttributeName = context.getProperty(IP_ADDRESS_ATTRIBUTE)
            .evaluateAttributeExpressions(flowFile).getValue();
    final String ipAttributeValue = flowFile.getAttribute(ipAttributeName);

    if (StringUtils.isEmpty(ipAttributeName)) {
        session.transfer(flowFile, REL_NOT_FOUND);
        getLogger().warn("FlowFile '{}' attribute '{}' was empty. Routing to failure",
                new Object[] { flowFile, IP_ADDRESS_ATTRIBUTE.getDisplayName() });
        return;
    }

    InetAddress inetAddress = null;
    IspResponse response = null;

    try {
        inetAddress = InetAddress.getByName(ipAttributeValue);
    } catch (final IOException ioe) {
        session.transfer(flowFile, REL_NOT_FOUND);
        getLogger().warn("Could not resolve the IP for value '{}', contained within the attribute '{}' in "
                + "FlowFile '{}'. This is usually caused by issue resolving the appropriate DNS record or "
                + "providing the processor with an invalid IP address ",
                new Object[] { ipAttributeValue, IP_ADDRESS_ATTRIBUTE.getDisplayName(), flowFile }, ioe);
        return;
    }
    final StopWatch stopWatch = new StopWatch(true);
    try {
        response = dbReader.isp(inetAddress);
        stopWatch.stop();
    } catch (final IOException | GeoIp2Exception ex) {
        // Note IOException is captured again as dbReader also makes InetAddress.getByName() calls.
        // Most name or IP resolutions failure should have been triggered in the try loop above but
        // environmental conditions may trigger errors during the second resolution as well.
        session.transfer(flowFile, REL_NOT_FOUND);
        getLogger().warn("Failure while trying to find enrichment data for {} due to {}",
                new Object[] { flowFile, ex }, ex);
        return;
    }

    if (response == null) {
        session.transfer(flowFile, REL_NOT_FOUND);
        return;
    }

    final Map<String, String> attrs = new HashMap<>();
    attrs.put(new StringBuilder(ipAttributeName).append(".isp.lookup.micros").toString(),
            String.valueOf(stopWatch.getDuration(TimeUnit.MICROSECONDS)));

    // During test I observed behavior where null values in ASN data could trigger NPEs. Instead of relying on the
    // underlying database to be free from Nulls wrapping ensure equality to null without assigning a variable
    // seem like good option to "final int asn ..." as with the other returned data.
    if (!(response.getAutonomousSystemNumber() == null)) {
        attrs.put(new StringBuilder(ipAttributeName).append(".isp.asn").toString(),
                String.valueOf(response.getAutonomousSystemNumber()));
    }
    final String asnOrg = response.getAutonomousSystemOrganization();
    if (asnOrg != null) {
        attrs.put(new StringBuilder(ipAttributeName).append(".isp.asn.organization").toString(), asnOrg);
    }

    final String ispName = response.getIsp();
    if (ispName != null) {
        attrs.put(new StringBuilder(ipAttributeName).append(".isp.name").toString(), ispName);
    }

    final String organisation = response.getOrganization();
    if (organisation != null) {
        attrs.put(new StringBuilder(ipAttributeName).append(".isp.organization").toString(), organisation);
    }

    flowFile = session.putAllAttributes(flowFile, attrs);

    session.transfer(flowFile, REL_FOUND);
}