Page 1 of 1

TimeStamp Difference

Posted: Tue Dec 19, 2006 3:09 pm
by Raftsman
Hi all,

I searched the forum for an answer and still I have not found one. My problem is,

I want to find the difference (right down to the microsecond) between two timestamps. I can see the timestamp and microseconds from the input but I can't seem to find a function that will allow me to do this. I thought of creating a server routine, but I don't think I will be able to see it in the Parallel Transformer.

Is there a solution on the forum that I didn't find or has someone come up with a BuildOp that will solve this problem.

Thanks.

Posted: Tue Dec 19, 2006 5:32 pm
by ray.wurlod
Does your version of Windows even deliver microseconds when a call is made to the system clock?

Posted: Tue Dec 19, 2006 8:46 pm
by Raftsman
The input comes from DB2 mainframe. I modified the field attributes with extended equal to microseconds. I can get the microseconds from DB2. What I was hoping to accomplish was write a routine or BuildOp that would take the start and end timestamps and provide the difference in seconds. I started to code a server routine only to find out that it wasn't visible in the PX transformer. I don't want to use the Basic Transformer. Another problem I encountered was trying to use DS functions within the coding. I am not sure if this is possible as well.

Thanks

Posted: Tue Dec 19, 2006 8:50 pm
by Raftsman
Also, no I can't get the microseconds from the system clock. I spoke with IBM and they said there may be a fix somewhere down the road. Hopefully, a simpler solution is created.

Posted: Tue Dec 19, 2006 9:46 pm
by clshore
Getting jitter free microsecond resolution from Wintel platform will be difficult. There are hardware plugs-ins that can easily resolve to that granularity, but associating the timestamp to the event still requires the CPU and OS, which are too often busy doing other things.

Here's a link to folks facing similar challenges:

http://www.csm.ornl.gov/~dunigan/atmgps/

In the end, it would be cheaper/easier to just use a UNIX box.

Carter

Posted: Tue Dec 19, 2006 9:47 pm
by clshore
Getting jitter free microsecond resolution from Wintel platform will be difficult. There are hardware plugs-ins that can easily resolve to that granularity, but associating the timestamp to the event still requires the CPU and OS, which are too often busy doing other things.

Here's a link to folks facing similar challenges:

http://www.csm.ornl.gov/~dunigan/atmgps/

In the end, it would be cheaper/easier to just use a UNIX box.

Carter

Posted: Tue Dec 19, 2006 10:39 pm
by ray.wurlod
Was the second post a "jitter on your Windows box"? :lol:

Posted: Tue Dec 19, 2006 10:41 pm
by ray.wurlod
Well, you can always work at the millisecond level, which IS supported. Indeed you can get the values for CPU and elapsed time (to millisecond accuracy, rounded) in log messages, so you don't even need to calculate them yourself.

Posted: Tue Dec 19, 2006 11:42 pm
by DSguru2B
You can write a c function. Use the time.h library. It has time structs that can get your work done. You can also do string manipulation within C. Read it like

Code: Select all

sscanf("%4d-%2d-%2 %2:%2:%2.%6d", &yr, &mo, &dy, &hh, &mm, &ss, &nn)
You can do the same for the second timestamp and minus them and return a concatenated value. This is a very general direction, for details you need to google it.

Posted: Wed Dec 20, 2006 1:18 am
by kumar_s
Use split micro seconds and rest of the portions. And you can use SecondsSinceFromTimestamp and multiply with 1000000. Add the microsecond and the resultant. Now you can manipulate as you wish.

Posted: Wed Dec 20, 2006 4:41 am
by ray.wurlod
All of which assumes that the OP can actually get microseconds from the system clock. On Windows platforms I suspect not, hence my first post on this thread.

Posted: Wed Dec 20, 2006 1:35 pm
by clshore
ray.wurlod wrote:Was the second post a "jitter on your Windows box"? :lol:
Yes, in fact it was!