Questions tagged [nanotime]

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the nanoseconds range.

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the nanoseconds (ns) range.

146 questions
0
votes
1 answer

System.nanoTime() diff is 0

I have the following piece of code to try and determine how long a method call takes to execute: long start = System.nanoTime(); diag(); // diag() is a native method, called via JNI. long finish = System.nanoTime(); System.out.println("update()…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
0
votes
1 answer

Extreme precise repeated/continuous code-execution

In my company, I have a program which must send some data via UDP to a remote system not under our control. The data must be send every 7981859ns (=7.98 milliseconds) +/- 0.001ms . Sadly, older versions of that remote-system are breaking if we…
Martin L.
  • 3,006
  • 6
  • 36
  • 60
0
votes
0 answers

Trying to measure how much time an insert takes in a database

I have a Multithreaded program which will insert into one of my table and that program I am running like this- java -jar CannedTest.jar 100 10000 which means: Number of threads is 100 Number of tasks is 10000 So each thread will insert 10000…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
0
votes
4 answers

Comparing methods speed performance using nanotime in Java

I would like to compare the speed performance (if there were any) from the two readDataMethod() as I illustrate below. private void readDataMethod1(List numbers) { final long startTime = System.nanoTime(); for (int i = 0; i <…
abiieez
  • 3,139
  • 14
  • 57
  • 110
0
votes
1 answer

java - system.nanoTime() runs too slow

I am using system.nanoTime in my app and I calculate time relative to a starttime. My app ran very well until I copied it to a new computer and on it the nano time gives me slower values. I wrote a simple app just to make sure. the nano time is…
Bick
  • 17,833
  • 52
  • 146
  • 251
-1
votes
1 answer

How to calculate nanoseconds from 1800

I'm trying to calculate the number of nano seconds that passed from: 11-Nov-1831 00:00:00.00 to a given date. I tried to use alot of packages but none of them succed in the mission (the closest was Instant) What's the best way to achive this…
emal
  • 11
  • 5
-1
votes
2 answers

Slow down a clock based on System.nanoTime();

I have a timer based on System.nanoTime() and I want to slow it down. I have this: elapsed = System.nanoTime(); seconds = ((elapsed - now) / 1.0E9F); where now is System.nanoTime(); called earlier in the class. In order to slow it down I…
user773737
-1
votes
2 answers

Calculating nanotime for Java's containsKey operation

I am trying to crate a code, which calculates Java Map's containsKey -operation in nanoseconds (like how fast it runs that operation). Method has a Map D as a parameter, and the value returned should be containsKey operations' normal…
-1
votes
2 answers

Which is the most reliable way to measure the performance speed of the methods in runtime in java

I want to measure the performance speed of my method in runtime execution but i am not sure if what i have done is really measured the performance of my method i want or is doing something else. If it is measuring the performance speed of my method…
Barlet South
  • 17
  • 1
  • 4
-3
votes
2 answers

Quicksort unsorted list running faster than sorted list

I'm getting weird timing results for quicksort with a first element pivot. My code runs quicksort first with an unsorted, non-randomized list of integers. It then sorts the previous sorted list. With my chosen pivot, I expected quicksort to run…
user1390616
  • 171
  • 1
  • 5
-4
votes
1 answer

How to get nanoTime from date?

I want nanoTime() of last 24 hours. long currentDate=System.nanoTime(); how to find nanoTime by subtracting 24 hours? Is it possible to get nanoTime from Date date = new Date()?
AmrutaH
  • 15
  • 6
1 2 3
9
10