Example usage for java.lang System nanoTime

List of usage examples for java.lang System nanoTime

Introduction

In this page you can find the example usage for java.lang System nanoTime.

Prototype

@HotSpotIntrinsicCandidate
public static native long nanoTime();

Source Link

Document

Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.

Usage

From source file:me.adaptive.core.data.api.UserTokenEntityService.java

private String getToken(UserEntity user) {
    StringBuilder builder = new StringBuilder(user.getUserId());

    builder.append(user.getUserId()).append(user.getPasswordHash()).append(System.nanoTime()).append(SALT);
    return String.valueOf(DigestUtils.sha256Hex(builder.toString()));
}

From source file:com.gwac.job.FitsFileCutServiceImpl.java

@Override
public void startJob() {

    if (isTestServer) {
        return;//w w w  .  j  ava  2 s  . co m
    }

    if (running == true) {
        log.debug("start job...");
        running = false;
    } else {
        log.warn("job is running, jump this scheduler.");
        return;
    }

    long startTime = System.nanoTime();
    try {//JDBCConnectionException or some other exception
        addMissedCutImages();
    } catch (Exception ex) {
        log.error("Job error", ex);
    } finally {
        if (running == false) {
            running = true;
        }
    }
    long endTime = System.nanoTime();
    log.debug("job consume " + 1.0 * (endTime - startTime) / 1e9 + " seconds.");
}

From source file:io.kahu.hawaii.util.call.statistics.RequestStatistic.java

public void startConversion() {
    startConversionNano = System.nanoTime();
}

From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java

public TimedAsyncHttpResponseHandler(Looper asyncHttpLooper, Context context) {
    super(asyncHttpLooper); // use a custom looper for async handler
    startTime = System.nanoTime();
    mContext = context; // context to get resources
}

From source file:com.xx_dev.apn.socks.local.FakeHttpClientDecoder.java

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    int startReaderIndex = in.readerIndex();

    long start = System.nanoTime();
    this._decode(ctx, in, out);
    long end = System.nanoTime();

    int endReaderIndex = in.readerIndex();

    perfLogger.debug("local decode: " + (endReaderIndex - startReaderIndex) + ", " + (end - start));

}

From source file:com.xx_dev.apn.socks.remote.FakeHttpServerDecoder.java

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    int startReaderIndex = in.readerIndex();

    long start = System.nanoTime();
    this._decode(ctx, in, out);
    long end = System.nanoTime();

    int endReaderIndex = in.readerIndex();

    perfLogger.debug("remote decode: " + (endReaderIndex - startReaderIndex) + ", " + (end - start));

}

From source file:com.github.sdbg.debug.core.util.JsonTests.java

public void xxx_test_parse100() throws IOException, JSONException {
    InputStream in = JsonTests.class.getResourceAsStream("test1.json.gz");
    GZIPInputStream gzipIn = new GZIPInputStream(in);
    String string = Streams.loadAndClose(new InputStreamReader(gzipIn, "UTF-8"));

    long start = System.nanoTime();

    int iterations = 100;

    for (int i = 0; i < iterations; i++) {
        @SuppressWarnings("unused")
        JSONObject obj = new JSONObject(string);
    }/*from  w  w w  .  jav a 2 s .co m*/

    long elapsed = System.nanoTime() - start;

    double mb = (string.length() * iterations) / (1024.0 * 1024.0);
    double sec = elapsed / (1000 * 1000 * 1000.0);

    System.out.println(String.format("%.2f MB/sec", (mb / sec)));
}

From source file:cloud.thrift.server.conf.ZooKeeperConfig.java

public ZkClient registService() {
    String servicePath = "/" + serviceName;// 
    ZkClient zkClient = new ZkClient(serverList);
    boolean rootExists = zkClient.exists(servicePath);
    if (!rootExists) {
        zkClient.createPersistent(servicePath);
    }/*w  ww  .j  a v a2s.c  o m*/
    InetAddress addr = null;
    try {
        addr = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    String ip = addr.getHostAddress().toString();
    String serviceInstance = System.nanoTime() + "-" + ip;
    // ??
    zkClient.createEphemeral(servicePath + "/" + serviceInstance);
    System.out.println("???" + servicePath + "/" + serviceInstance);
    return zkClient;
}

From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.TimeablePostMethod.java

public long getTimeTakenUntilNow() {
    long nanoTime = System.nanoTime();
    long result = ((nanoTime - startTime) + 500000) / 1000000;

    if (result == 0) {
        System.out.println("time taken = 0 ms; " + (nanoTime - startTime) + " ns");
        result = 1;//from  w w w  .  j  a  v a 2s.  c om
    }

    return result;
}

From source file:io.kahu.hawaii.util.call.statistics.RequestStatistic.java

public void endConversion() {
    endConversionNano = System.nanoTime();
}