当前位置: 首页>>代码示例>>Java>>正文


Java TimeUnit.MICROSECONDS属性代码示例

本文整理汇总了Java中java.util.concurrent.TimeUnit.MICROSECONDS属性的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit.MICROSECONDS属性的具体用法?Java TimeUnit.MICROSECONDS怎么用?Java TimeUnit.MICROSECONDS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.concurrent.TimeUnit的用法示例。


在下文中一共展示了TimeUnit.MICROSECONDS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toTimeUnit

/**
 * To time unit time unit.
 *
 * @param tu the tu
 * @return the time unit
 */
public static TimeUnit toTimeUnit(final ChronoUnit tu) {
    if (tu == null) {
        return null;
    }
    switch (tu) {
        case DAYS:
            return TimeUnit.DAYS;
        case HOURS:
            return TimeUnit.HOURS;
        case MINUTES:
            return TimeUnit.MINUTES;
        case SECONDS:
            return TimeUnit.SECONDS;
        case MICROS:
            return TimeUnit.MICROSECONDS;
        case MILLIS:
            return TimeUnit.MILLISECONDS;
        case NANOS:
            return TimeUnit.NANOSECONDS;
        default:
            throw new UnsupportedOperationException("Temporal unit is not supported");
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:DateTimeUtils.java

示例2: configureConnector

@Override
protected void configureConnector ( final NioSocketConnector connector )
{
    logger.debug ( "Configuring connector: {}", connector );

    switch ( this.protocolType )
    {
        case TYPE_TCP:
            connector.getFilterChain ().addLast ( "modbusPdu", new ProtocolCodecFilter ( new ModbusTcpEncoder (), new ModbusTcpDecoder () ) );
            connector.getFilterChain ().addLast ( "modbus", new ModbusMasterProtocolFilter () );
            break;
        case TYPE_RTU:
            // convert milliseconds to microseconds to allow more accurate timing
            final ModbusRtuDecoder rtuDecoder = new ModbusRtuDecoder ( getExecutor (), Double.valueOf ( this.interFrameDelay * 1000 ).longValue (), TimeUnit.MICROSECONDS );
            connector.getFilterChain ().addLast ( "modbusPdu", new ModbusRtuProtocolCodecFilter ( new ModbusRtuEncoder (), rtuDecoder ) );
            connector.getFilterChain ().addLast ( "modbus", new ModbusMasterProtocolFilter () );
            break;
        default:
            throw new IllegalArgumentException ( String.format ( "'%s' is not an allowed modbus device type", this.protocolType ) );
    }

    if ( Boolean.getBoolean ( "org.eclipse.scada.da.server.osgi.modbus.trace" ) )
    {
        connector.getFilterChain ().addFirst ( "logger", new LoggingFilter ( ModbusMaster.class.getName () + ".protocol" ) );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:ModbusMaster.java

示例3: toTimeUnit

/**
 * Convert a protocol buffer TimeUnit to a client TimeUnit
 * @param proto
 * @return the converted client TimeUnit
 */
public static TimeUnit toTimeUnit(final HBaseProtos.TimeUnit proto) {
  switch (proto) {
  case NANOSECONDS:
    return TimeUnit.NANOSECONDS;
  case MICROSECONDS:
    return TimeUnit.MICROSECONDS;
  case MILLISECONDS:
    return TimeUnit.MILLISECONDS;
  case SECONDS:
    return TimeUnit.SECONDS;
  case MINUTES:
    return TimeUnit.MINUTES;
  case HOURS:
    return TimeUnit.HOURS;
  case DAYS:
    return TimeUnit.DAYS;
  default:
    throw new RuntimeException("Invalid TimeUnit " + proto);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ProtobufUtil.java

示例4: getRSForFirstRegionInTable

/**
 * Tool to get the reference to the region server object that holds the
 * region of the specified user table.
 * It first searches for the meta rows that contain the region of the
 * specified table, then gets the index of that RS, and finally retrieves
 * the RS's reference.
 * @param tableName user table to lookup in hbase:meta
 * @return region server that holds it, null if the row doesn't exist
 * @throws IOException
 * @throws InterruptedException
 */
public HRegionServer getRSForFirstRegionInTable(TableName tableName)
    throws IOException, InterruptedException {
  List<byte[]> metaRows = getMetaTableRows(tableName);
  if (metaRows == null || metaRows.isEmpty()) {
    return null;
  }
  LOG.debug("Found " + metaRows.size() + " rows for table " +
    tableName);
  byte [] firstrow = metaRows.get(0);
  LOG.debug("FirstRow=" + Bytes.toString(firstrow));
  long pause = getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE,
    HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
  int numRetries = getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
    HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
  RetryCounter retrier = new RetryCounter(numRetries+1, (int)pause, TimeUnit.MICROSECONDS);
  while(retrier.shouldRetry()) {
    int index = getMiniHBaseCluster().getServerWith(firstrow);
    if (index != -1) {
      return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();
    }
    // Came back -1.  Region may not be online yet.  Sleep a while.
    retrier.sleepUntilNextRetry();
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:HBaseTestingUtility.java

示例5: registerMBean

public void registerMBean(Metric metric, ObjectName name)
{
    AbstractBean mbean;

    if (metric instanceof Gauge)
    {
        mbean = new JmxGauge((Gauge<?>) metric, name);
    } else if (metric instanceof Counter)
    {
        mbean = new JmxCounter((Counter) metric, name);
    } else if (metric instanceof Histogram)
    {
        mbean = new JmxHistogram((Histogram) metric, name);
    } else if (metric instanceof Meter)
    {
        mbean = new JmxMeter((Meter) metric, name, TimeUnit.SECONDS);
    } else if (metric instanceof Timer)
    {
        mbean = new JmxTimer((Timer) metric, name, TimeUnit.SECONDS, TimeUnit.MICROSECONDS);
    } else
    {
        throw new IllegalArgumentException("Unknown metric type: " + metric.getClass());
    }

    try
    {
        mBeanServer.registerMBean(mbean, name);
    } catch (Exception ignored) {}
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:29,代码来源:CassandraMetricsRegistry.java

示例6: calculateLocationReport

/**
 * This method calculates location inter-report times.
 * @param traces location traces belong to a person
 * @param unit time unit
 * @return inter-report times
 * @throws InsufficientLocationTraceException
 * @throws TimeUnitNotSupportedException 
 */
public long[] calculateLocationReport(List<LocationTrace> traces, 
		TimeUnit unit) throws InsufficientLocationTraceException, TimeUnitNotSupportedException {

	if (traces == null || traces.size() < minimumNumberOfTraces) {
		throw new InsufficientLocationTraceException("LocationTrace list "
				+ "need to have at least " + minimumNumberOfTraces
				+ " elements.");
	}

	if (unit == TimeUnit.NANOSECONDS || unit == TimeUnit.MICROSECONDS
			|| unit == TimeUnit.MILLISECONDS) {
		throw new TimeUnitNotSupportedException(
				unit + " is not supported. Please pass seconds or above as time unit.");
	}
	
	long[] locationReportTimes = new long[ traces.size() - 1];
	
	DateTime date1 = traces.get(0).getUTCTime();
	DateTime date2;
	
	for (int i=1; i < traces.size(); i++){
		date2 = traces.get(i).getUTCTime();
		
		locationReportTimes[i - 1] = calculateDuration(date1, date2, unit);
		
		date1 = date2;
	}
	
	return locationReportTimes;
}
 
开发者ID:hamdikavak,项目名称:human-mobility-modeling-utilities,代码行数:38,代码来源:LocationReport.java

示例7: parseTimeValue

public static TimeValue parseTimeValue(String sValue, TimeValue defaultValue, String settingName) {
    settingName = Objects.requireNonNull(settingName);
    if (sValue == null) {
        return defaultValue;
    }
    final String normalized = sValue.toLowerCase(Locale.ROOT).trim();
    if (normalized.endsWith("nanos")) {
        return new TimeValue(parse(sValue, normalized, 5), TimeUnit.NANOSECONDS);
    } else if (normalized.endsWith("micros")) {
        return new TimeValue(parse(sValue, normalized, 6), TimeUnit.MICROSECONDS);
    } else if (normalized.endsWith("ms")) {
        return new TimeValue(parse(sValue, normalized, 2), TimeUnit.MILLISECONDS);
    } else if (normalized.endsWith("s")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.SECONDS);
    } else if (sValue.endsWith("m")) {
        // parsing minutes should be case sensitive as `M` is generally
        // accepted to mean months not minutes. This is the only case where
        // the upper and lower case forms indicate different time units
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.MINUTES);
    } else if (normalized.endsWith("h")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.HOURS);
    } else if (normalized.endsWith("d")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.DAYS);
    } else if (normalized.matches("-0*1")) {
        return TimeValue.MINUS_ONE;
    } else if (normalized.matches("0+")) {
        return TimeValue.ZERO;
    } else {
        // Missing units:
        throw new ElasticsearchParseException(
            "failed to parse setting [{}] with value [{}] as a time value: unit is missing or unrecognized",
            settingName,
            sValue);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:TimeValue.java

示例8: readTimeUnit

/**
 * Reads a <code>TimeUnit</code> from a <code>DataInput</code>.
 *
 * @throws IOException A problem occurs while writing to <code>out</code>
 */
public static TimeUnit readTimeUnit(DataInput in) throws IOException {

  InternalDataSerializer.checkIn(in);

  byte type = in.readByte();

  TimeUnit unit;
  switch (type) {
    case TIME_UNIT_NANOSECONDS:
      unit = TimeUnit.NANOSECONDS;
      break;
    case TIME_UNIT_MICROSECONDS:
      unit = TimeUnit.MICROSECONDS;
      break;
    case TIME_UNIT_MILLISECONDS:
      unit = TimeUnit.MILLISECONDS;
      break;
    case TIME_UNIT_SECONDS:
      unit = TimeUnit.SECONDS;
      break;
    default:
      throw new IOException(LocalizedStrings.DataSerializer_UNKNOWN_TIMEUNIT_TYPE_0
          .toLocalizedString(Byte.valueOf(type)));
  }

  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Read TimeUnit: {}", unit);
  }

  return unit;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:36,代码来源:InternalDataSerializer.java

示例9:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfFieldsBenchmark(final LotsOfFieldsBenchmark.BenchmarkState benchmarkState) {
    return createIEXMessage(benchmarkState.packet);
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j-hist,代码行数:6,代码来源:LotsOfFieldsBenchmark.java

示例10:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXSegment bigSegmentBenchmark(final BenchmarkState benchmarkState) {
    return createIEXSegment(benchmarkState.packet);
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j-hist,代码行数:6,代码来源:BigSegmentBenchmark.java

示例11:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfEnumsBenchmark(final LotsOfEnumsBenchmark.BenchmarkState benchmarkState) {
    return createIEXMessage(benchmarkState.packet);
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j-hist,代码行数:6,代码来源:LotsOfEnumsBenchmark.java

示例12:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void measureAvgTime() throws InterruptedException {
    TimeUnit.MILLISECONDS.sleep(100);
}
 
开发者ID:mumudemo,项目名称:mumu-benchmark,代码行数:6,代码来源:JMHSample_02_BenchmarkModes.java

示例13: newRecorder

private Recorder newRecorder() {
  return new Recorder(MIN_DURATION, MAX_DURATION, GOAL_DURATION, TimeUnit.MICROSECONDS);
}
 
开发者ID:codahale,项目名称:grpc-proxy,代码行数:3,代码来源:StatsTracerFactory.java

示例14: run

@Override
public void run() {
  try {
    final TlsContext tls = new TlsContext(trustedCertsPath, certPath, keyPath);
    final HelloWorldClient client = new HelloWorldClient(hostname, port, tls);
    try {
      final Recorder recorder =
          new Recorder(
              500,
              TimeUnit.MINUTES.toMicros(1),
              TimeUnit.MILLISECONDS.toMicros(10),
              TimeUnit.MICROSECONDS);
      LOGGER.info("Initial request: {}", client.greet(requests));
      LOGGER.info("Sending {} requests from {} threads", requests, threads);

      final ExecutorService threadPool = Executors.newFixedThreadPool(threads);
      final Instant start = Instant.now();
      for (int i = 0; i < threads; i++) {
        threadPool.execute(
            () -> {
              for (int j = 0; j < requests / threads; j++) {
                final long t = System.nanoTime();
                client.greet(j);
                recorder.record(t);
              }
            });
      }
      threadPool.shutdown();
      threadPool.awaitTermination(20, TimeUnit.MINUTES);

      final Snapshot stats = recorder.interval();
      final Duration duration = Duration.between(start, Instant.now());
      LOGGER.info(
          Markers.append("stats", stats).and(Markers.append("duration", duration.toString())),
          "{} requests in {} ({} req/sec)",
          stats.count(),
          duration,
          stats.throughput());
    } finally {
      client.shutdown();
    }
  } catch (SSLException | InterruptedException e) {
    LOGGER.error("Error running command", e);
  }
}
 
开发者ID:codahale,项目名称:grpc-proxy,代码行数:45,代码来源:HelloWorldClient.java

示例15: updateTime

private double updateTime(double avg, TimeUnit timeUnit2) {
	if (timeUnit == TimeUnit.MILLISECONDS)
		avg = avg * 1000;
	// avg = TimeUnit.MILLISECONDS.toMillis(avg);

	if (timeUnit == TimeUnit.MICROSECONDS)

		avg = avg * 1000 * 1000;

	if (timeUnit == TimeUnit.NANOSECONDS)
		avg = avg * 1000 * 1000 * 1000;

	// avg = TimeUnit.MILLISECONDS.toNanos(avg);

	if (timeUnit == TimeUnit.SECONDS)
		; // already in sec

	return avg;
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:19,代码来源:HistoryChartGenerator.java


注:本文中的java.util.concurrent.TimeUnit.MICROSECONDS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。