How to get number of miliseconds since epoch in ADF - azure

I am trying hard to get Unix Timestamp for current time in ADF. Basically I need number of number of milliseconds (ms) since epoch. I tried dabbling with built-in ticks function in ADF but it's not what I need. Also the documentation on the ticks is not really clear. It says number of ticks since specified timestamp is what the function returns. 1 tick = 100 nanoseconds & 1000000 nanoseconds = 1 ms. So considering this, I used the following expression in set variable activity:-
#{ div(ticks('1970-01-01T00:00:00.0000000Z'),10000) }
So the expectation is that whenever I run it, it should give me number of milliseconds since the epoch ( up to the moment of execution ) -- so by this definition every time I run it, it should return me a different value. But it returns a fixed value 62135568000000 every time I run it. So either the documentation is not correct or it's not really calculating what I really need.

Function ticks() return the number of ticks from '0001-01-01T00:00:00.0000000Z' to parameter of ticks(), not from '1970-01-01T00:00:00.0000000Z'.This is why you always get a fixed value 62135568000000.
I have tried #{ticks('0001-01-01T00:00:00.0000000Z')}, result is 0.
So if you want to get ms from '1970-01-01T00:00:00.0000000Z' to current time, you can try this:#{div(sub(ticks(utcnow()),ticks('1970-01-01T00:00:00.0000000Z')),10000)}.

Related

What time are the process.hrtime() and process.hrtime.bigint() functions referring to in Node.js?

the process.hrtime() is a legacy version of process.hrtime.bigint() method
process.hrtime(); // -> [27511, 516453000] (seconds, remaining nanoseconds)
process.hrtime.bigint(); // -> 27511516453000n (nanoseconds)
27511516453000 nanoseconds are 7.6420879036111113 hours
When I'm Testing this the time is 11:54 UTC and 14:54 Locale Time
the 7.64 hours does not refer to the current time so what is that 7.64 hours are referring to?
The meaning of these values is defined in the documentation (although it's easy to miss, since it's just one line):
These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift.
So in other words, hrtime is only useful for calculating the time relative to another point in time. If you call hrtime now, and then again ten seconds in the future, the result of subtracting the former from the latter will equal ten seconds. The values returned by those two calls, however, have no real meaning in isolation from each other.

How to wait x seconds in 6502 basic

How do I wait x amount of time in basic 6502? I am on VICE xpet, and I would like to print a character, wait a little, then delete it, and repeat for a while, as a sort of status indicator. The only problem is that it deletes to fast so the indicator never shows up. I've tried looking for such a command on the reference, but there is nothing for just flat out waiting a little bit. I know that if I make a huge for loop I may be able to slow the machine down enough to do it by brute force, but I'd rather avoid such if possible. Is there not a better way?
Thanks!
You can refer to the system variable TI for timing purposes. Value of the variable incremented automatically in 1/60 seconds. It will not be perfect but it works.
Below example will print current value of TI for each second:
10 PRINT "START " TI
20 T0=T1
30 IF TI-T0>=60 THEN PRINT TI;TI-T0 : GOTO 20
40 GOTO 30
It's been decades since I've programmed on a 6502 (C-64/VIC-20) but I'm pretty sure even their version of BASIC had the keyword TIMER. If memory serves, it counts milliseconds, but I could be wrong. You might have to play with it. Set a variable equal to TIMER, do a for/next loop to take up some time, then check its value again. Once you figure out how many ticks occur in a second, you'll be able to make that a constant and then loop until variable = timer start plus constant ticks per second (first setting variable to timer before loop, of course).

Using time.strf() to get the current time, and building on that

I have this code below:
interval_time=int(input('how many seconds each interval?'))
print(time.strftime("%H:%M"))
while time.strftime("%H:%M")!=str('19:45'):
time.sleep(interval_time)
winsound.PlaySound("SystemExit",winsound.SND_ALIAS)
winsound.PlaySound("SystemEnter",winsound.SND_ALIAS)
The thing is, I know how to get current time. I want it to look something like:
while *script_first_ran_time*!=*script_first_ran_time+30minutes*
I know how to convert the minutes, but it keeps re-taking the current time and adding 30 minutes to it. How do I make the initial time.strf() remain constant?
Thanks a lot!
You've decided to make this task harder by using string representation of times. As these strings have no concept of being dates, performing date-related operations on them is troublesome. As an alternative, you should use dedicated library designed to work with dates and times, namely datetime.
Boilerplate code would look like this:
from datetime import datetime, timedelta
thirty_minutes_later = datetime.now() + timedelta(minutes=30)
while datetime.now() < thirty_minutes_later:
pass # do something
Here, datetime.now returns special objects that represents current time. timedelta returns special objects that, when added or subtracted from datetime instance, returns another datetime, shifted in time according to timedelta's state.
Also, notice that I've changed your condition from not equal to bigger than - it'll stop processing even if you won't hit your time spot precisely (and with millisecond resolution, you'd have to be extremely lucky to hit that).

Difference between Think time and Pacing Time in Performace testing

Pacing is used to achieve X number of iterations in X minutes, But I'm able to achieve x number of iterations in X minutes or x hours or x seconds by specifying only think time without using pacing time.
I want to know the actual difference between think time and pacing time? pacing time is necessary to mention between iterations? what this pacing time does?
Think time is a delay added after iteration is complete and before the next one is started. The iteration request rate depends on the sum of the response time and the think time. Because the response time can vary depending on a load level, iteration request rate will vary as well.
For constant request rate, you need to use pacing. Unlike think time, pacing adds a dynamically determined delay to keep iteration request rate constant while the response time can change.
For example, to achieve 3 iteration in 2 minutes, pacing time should be 2 x 60 / 3 = 40 seconds. Here's an example how to use pacing in our tool http://support.stresstimulus.com/display/doc46/Delay+after+the+Test+Case
Think Time
it introduces an element of realism into the test execution.
With think time removed, as is often the case in stress testing, execution speed and throughput can increase tenfold, rapidly bringing an application infrastructure that can comfortably deal with a thousand real users to its knees.
always include think time in a load test.
think time influences the rate of transaction execution
Pacing
another way of affecting the execution of a performance test
affects transaction throughput

Node.js: When does process.hrtime start

What is the starting time for process.hrtime (node.js version of microTime)? I couldn't find any event that starts it. Is the timestamp of the start saved anywhere?
I need my server to be able to get latency to client both ways and for that, I need reliable microtime measure. (+ for some other things)
The starting time is arbitrary; its actual value alone is meaningless. Call hrtime when you want to start the stopwatch, and call it again when your operation is done. Subtract the former from the latter and you have the elapsed time.
process.hrtime()
Returns the current high-resolution real time in a
[seconds, nanoseconds] tuple Array. It is relative to an arbitrary
time in the past. It is not related to the time of day and therefore
not subject to clock drift. The primary use is for measuring
performance between intervals.
You may pass in the result of a previous call to process.hrtime() to
get a diff reading, useful for benchmarks and measuring intervals:

Resources