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

The problem with using System.nanoTime() for calculating the working time of the method

I want to know the working time of some methods in my study project by Java tools. When I tried to use System.nanoTime(), I had noticed, that comparison of the working time of two methods looks a litle bit strange. The first and the second methods…
richi_urb
  • 9
  • 1
0
votes
0 answers

Is there an equivalent to System.nanoTime() which do not change when changing the system time?

At least on my Linux computer, changing the time of the system affects System.nanoTime(), making it unreliable to determine an interval if the time of the system is changed during that interval. Is there an equivalent to this function which do not…
Winter
  • 3,894
  • 7
  • 24
  • 56
0
votes
0 answers

System.nanoTime() when being called more than once, does not work properly

I have DurationTime to count time for DIjkstra Algorithm for different graphs with different numVertices. When I call the DurationTime for the 1st time the duration is:1.5+ sec and for the next calls the duration is around 0.1-0.3 sec. public static…
Omnni777
  • 3
  • 1
0
votes
2 answers

problems utilitizing small pauses in c code using nanosleep

I am a C beginner and trying this and that. I want to display a string letter by letter with tiny pauses in between. So my idea was a small pause using sleep or usleep after displaying each char but I read that using nanosleep in your own function…
0
votes
1 answer

Use int64 nanotimes as array dimnames in R

I have some lovely nanotimes: > mynames [1] "2020-04-15T00:29:00.000000000+00:00" "2020-04-15T00:33:00.000000000+00:00" Which I'd like to add as dimnames to my array: > a [,1] [,2] [1,] NA NA [2,] NA NA However, they seem to be…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
0
votes
1 answer

How to compute the total execution time in multithread application

There is an application that I need to test to see the relationship between number of threads and the total duration of an execution in an multithreaded application. That is what I am trying at the moment: //Start time of thread executions. …
zodiac645
  • 191
  • 1
  • 3
  • 14
0
votes
1 answer

Java nanoTime not throwing reliable results

I am doing a project where I need to implement bubblesort, shellsort and quicksort algorithms in an array of 999 random doubles. I need to measure the time it takes every algorithm to run. I am using System.nanoTime() to measure this execution time…
Dasphillipbrau
  • 524
  • 2
  • 8
  • 17
0
votes
1 answer

nanotime: how to deal with NAs in a tibble?

I am using the excellent nanotime package to store my timestamps, but I am unable to make the package work when my tibble contains a missing value. Consider this: library(nanotime) library(tibble) library(dplyr) tibble(time = c('2020-01-01…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
1 answer

how to safely store millisecond differences between timestamps?

This is some hellish question related to floating-point approximations and timestamps in R. Get ready :) Consider this simple example: library(tibble) library(lubridate) library(dplyr) tibble(timestamp_chr1 = c('2014-01-02 01:35:50.858'), …
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
1 answer

.toNanos() method does not work correctly

I tried to make a method that will give me an idea of how much time it takes to my programs to run, and for an unknown reason, I can not get the nanoseconds. I tried to read about the below classes but could not find out what I am doing…
David
  • 145
  • 1
  • 3
  • 13
0
votes
1 answer

How do I find the total amount of nanoseconds from deltatime (datetime)?

I am trying to get the current time in nanoseconds from the exact start of 01/01/2010 I thought about just multiplying the total seconds by 1e+9, however I don't know how accurate that would be. I've also tried to use .total_nanoseconds(), however…
0
votes
2 answers

how to convert a nanotime to character?

Consider this simple example DT <- data.table::data.table(mytime = c(nanotime('2011-12-05 08:30:00.000',format ="%Y-%m-%d %H:%M:%E9S", tz ="GMT"), nanotime('2011-12-05 08:30:00.100',format ="%Y-%m-%d %H:%M:%E9S", tz…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
1 answer

how to extract year, tz-convert and get millisecond part from a nanotime timestamp?

I am using the amazing nanotime package to store my precious timestamps. Consider this: library(tibble) library(nanotime) tibble(mytimestamp = c(nanotime('2011-12-05 08:30:00.000',format ="%Y-%m-%d %H:%M:%E9S", tz ="GMT"), …
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
0 answers

Logging accurate timestamps in a java multithread environment

How do i make sure that timestamps belonging to certain events are actually created and logged right at the same time that the event happened when multiple threads are running? class Thread1 extends Thread { void run() { executeTask1(); …
nveo
  • 361
  • 1
  • 2
  • 9
0
votes
1 answer

Timing an insertion sort of different lenghts with System.nanoTime()

I have some code, in Java, to time the average of 10 tries of an insertion sort. It sorts the same array but up to 100 words, 200 words etc. up until the full lenght of on array. The code below is for 100 and 200 words respectively but it all looks…
biner1999
  • 35
  • 4