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
2
votes
0 answers

Nanotime formatting with underscore separator for fractional seconds

Working with nanoseconds from epoch is a breeze with nanotime, e.g.: > x <- 1639142792837258898 > xn <- nanotime::nanotime(x) > xn [1] 2021-12-10T22:26:32.837259008+09:00 > format(xn, format = "%Y-%m-%dT%H:%M:%E9S") [1]…
Ryogi
  • 5,497
  • 5
  • 26
  • 46
2
votes
2 answers

Full execution time multi thread java

I want to measure the full execution time (when ALL threads are done). But my code won't work here, because when the main-method ends while the other threads will still be running because they take longer time to process than the…
Eckerd
  • 21
  • 3
2
votes
2 answers

Measure Epoch time in Nanoseconds - Android

How to find the time since Epoch in nanoseconds in Android? Below APIS are available but they just give the time since boot SystemClock.elapsedRealtimeNanos() - Time since boot but includes deep sleep time System.getnano() -> This is up time since…
Sandeep
  • 18,356
  • 16
  • 68
  • 108
2
votes
1 answer

System.nanoTime() returns different values between java 7 and java 8

System.nanoTime() returns different values when the same code is compiled and run against java 7 and java 8. This piece of code: public class nanoTime { public static void main(String... args) { System.out.println("Found JVM: " …
karth
  • 635
  • 3
  • 13
  • 25
2
votes
0 answers

Exact Time Measuring for Cognitive Experiments

we have a java program being used for some cognitive diagnosis in which we have to measure time the most exact way possible. till now it has used psychtoolbox to perform these measurements, but since moving from XP to win7 there is a significant…
Spätzle
  • 709
  • 10
  • 20
2
votes
2 answers

Why Java System.timeNano() shows the same time?

I want to test the runtime of some sorting algorithm with the following code int n = 2000; for(int i=0; i<10; i++){ n *= 2; init(array, n); // initializes array with n elements long startTime = System.nanoTime(); sort(array; long…
Andy
  • 43
  • 1
  • 5
2
votes
1 answer

Which is better for timing, nanoTime or elapsedRealtimeNanos?

Both seem to be appropriate for timing things on Android. How are they different? Which one is best for timing?
meisel
  • 2,151
  • 2
  • 21
  • 38
2
votes
2 answers

Nano and milliseconds

long startTime = System.nanoTime(); long startTimer = System.currentTimeMillis(); M = app.decriptare_simpla(C); long endTime = System.nanoTime(); long stopTimer = System.currentTimeMillis(); //mesajul initial dupa…
George Irimiciuc
  • 4,573
  • 8
  • 44
  • 88
2
votes
2 answers

Nanosecond Accuracy For Timing In C++

Is there a way in C++ to get nanosecond accuracy? Something equivalent to the nanosecond timer in Java (System.nanotime).
Monet R. Adams
  • 115
  • 3
  • 8
2
votes
2 answers

Resolution of a nanoTime() Timer

I have searched the postings for an answer related to the time which the System.nanoTime( ) method call takes to process. Consider the following code: long lastTime = System.nanoTime(); long currentTime = System.nanoTime(); long deltaTime =…
Jonathan
  • 589
  • 1
  • 13
  • 23
2
votes
3 answers

System.nanotime running slow?

One of my friends showed me something he had done, and I was at a serious loss to explain how this could have happened: he was using a System.nanotime to time something, and it gave the user an update every second to tell how much time had elapsed…
DivineWolfwood
  • 1,752
  • 12
  • 20
2
votes
1 answer

What are the advantages of Guava Stopwatch class?

In the Google Guava library, there is a Stopwatch class, and its documentation states this - An object that measures elapsed time in nanoseconds. It is useful to measure elapsed time using this class instead of direct calls to …
Quest Monger
  • 8,252
  • 11
  • 37
  • 43
1
vote
1 answer

Why does my search time get shorter the more searches I do?

I'm doing an assignment that requires me to measure the time taken by two different search algorithms, sequential and binary (I suppose to make the point about efficiency). I have a target list of about 280 words to look for and a search pool list…
Katherine Rix
  • 672
  • 2
  • 8
  • 18
1
vote
3 answers

What's wrong with System.nanoTime?

I have a very long string with the pattern at the very end, I am trying to test the performance of some function calls, so I made the following test to try to find out the answer... but I think I might be using nanoTime incorrectly? Because…
codenamezero
  • 2,724
  • 29
  • 64
1
vote
1 answer

Support of nanotime by RSQLite

I am looking into what is required to support nanotime objects in RSQLite queries. They are just integer64 wrappers. Here is an example: con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:", bigint = "integer64") ts <-…
Davor Josipovic
  • 5,296
  • 1
  • 39
  • 57