Compute in milisecond by use of mktime


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compute in milisecond by use of mktime
# 1  
Old 06-14-2013
Compute in milisecond by use of mktime

Hi,

I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond

Code:
Starttime 2013-04-03 08:54:19,989
End time  2013-04-03 08:54:39,389

# 2  
Old 06-14-2013
Most systems don't have a mktime for shell programming... What's your system? uname -a

Last edited by Corona688; 06-14-2013 at 12:34 PM..
# 3  
Old 06-14-2013
Java

I'm using awk' mktime feature
# 4  
Old 06-14-2013
Quote:
Originally Posted by random_thoughts
I'm using awk' mktime feature
It can be done by combining parsing and mktime as mktime alone cannot adjust for the millisecs in the input.
Parse the date/time field using gensub and feed it to mktime which gives seconds since the Epoch.
Then convert those seconds into milliseconds and add the ones provided in the input.
Once you have the time in milliseconds subtract the endtime from the starttime.
# 5  
Old 06-15-2013
Quote:
Originally Posted by random_thoughts
I'm using awk' mktime feature
No you are not - you are using gawk's mktime function. Neither, oark or nawk have a mktime function. Not sure about mawk but i do not think so.
# 6  
Old 06-17-2013
Yes, I am using gawk.

---------- Post updated at 06:46 AM ---------- Previous update was at 06:43 AM ----------
GNU Awk 3.1.3

Last edited by random_thoughts; 06-19-2013 at 05:41 AM..
# 7  
Old 06-17-2013
Quote:
Originally Posted by random_thoughts
Yes, I am using gawk.

---------- Post updated at 06:46 AM ---------- Previous update was at 06:43 AM ----------

Linux 2.6.9-78.ELsmp i686 i686 i386 GNU/Linux
Btw did you use the steps I listed to come up with a [g]awk script...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compute value from more than three consecutive rows

Hello all, I am working on a file like below: site Date time value1 value2 0023 2014-01-01 00:00 32.0 23.7 0023 2014-01-01 01:00 38.0 29.9 0023 2014-01-01 02:00 85.0 26.6 0023 2014-01-01 03:00 34.0 25.3 0023 2014-01-01 04:00 37.0 23.8 0023 2014-01-01 05:00 80.0 20.3 0023 2014-01-01 06:00... (16 Replies)
Discussion started by: kathy wang
16 Replies

2. UNIX for Beginners Questions & Answers

Forward Display from compute node

Hello, sorry if this is an easy thing, but I tried to make it run the whole morning, but it doesn't work so far... I am logged in on a visualization node of a high performance cluster. On this node I can run several gui-based software for the postprocessing of my cfd-data. As the... (1 Reply)
Discussion started by: Shlaeae
1 Replies

3. Shell Programming and Scripting

awk mktime(strftime(format,"6-FEB-2013 08:50:03.841")

I'm trying to use AWK to filter on some dates in a field by converting them to Unix Time. mktime(strftime(format,"6-FEB-2013 08:50:03.841")What is the proper format for my date strings as they appear in my database? My first thought is %d-%b-%Y %H:%M:%Sbut I see the following issues: %d is... (3 Replies)
Discussion started by: Michael Stora
3 Replies

4. UNIX for Advanced & Expert Users

[SOLVED] Making mktime/strftime available to mawk

I frequently use awk time functions and am switching some scripts over to mawk. I don't have the mktime or strftime functions in mawk, but it appears that there is a way, as explained here in "Time functions": Please only cut-and-past links to man pages from our man pages. So, simple... (10 Replies)
Discussion started by: treesloth
10 Replies

5. Shell Programming and Scripting

Compute Difference and Edit second, third columns

Hi Friends, My input file is like this chr1 100 200 chr1 300 330 chr1 2000 2000 chr1 5000 5000 chr2 7790 7890 chr2 8000 8000 If the difference of third and second columns is zero, then subtract 500 from second column and add 500 to the third column. So, my output would be chr1... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

6. Web Development

How to compute previous and next buttons?

I have a project to migrate my club's membership database from Access to web based using MySQL/PHP, but I have a problem I can't get my head around and would appreciate some help... Background... I want to be able to display each member's data on screen and add a Previous and Next button to move... (2 Replies)
Discussion started by: JerryHone
2 Replies

7. Shell Programming and Scripting

Compute difference between 2 arrays perl

Hi, I have 2 arrays. I have to compute symmetric difference! @arr=qw(19205134 18630215 18453487 18416242 18338715 18227590 17698645); @arr1=qw(18227590 18053561 17698645 16966777); #The code which i used is this! @union = @isect = @diff = (); %union = %isect = (); %count =... (3 Replies)
Discussion started by: vanitham
3 Replies

8. Shell Programming and Scripting

compute compilation time using script

Hi, I use this script to compute compilation time several time to get system performance and compare different system: #!/bin/sh # measure the different between time before and # after the compilation of benchmark # Start at iteration 1 num=1 while do # Add one to the iteration... (3 Replies)
Discussion started by: zainab
3 Replies

9. Shell Programming and Scripting

to compute diskspace

Guys, have any idea for the script like this? also to compute w/ decimal. thanks a=10 b=20 c=30 d=40 if a < b then ( a -b)*1024 = free space b + (c -d) = total space if a > b then (b / d)*1024 = cpu (3 Replies)
Discussion started by: kenshinhimura
3 Replies

10. Shell Programming and Scripting

compute total from a text file

Hi, I've encountered a problem with a perl and ksh script that totals a certain field in a text file. The computed total of the script is 295540304 but the expected is 297959288, a 2 million difference. The KSH script reads from bottom to top, and the discrepancy started on line 47 (1279th MAN... (1 Reply)
Discussion started by: rsf01
1 Replies
Login or Register to Ask a Question