?
Solved

get milliseconds in linux

Posted on 2003-03-03
10
Medium Priority
?
6,083 Views
Last Modified: 2008-01-16
how can i get milliseconds from bash, i will use it in a script, i can't write c++
0
Comment
Question by:inudaci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 9

Expert Comment

by:majorwoo
ID: 8062432
millisenods for the current(system) time or what?

you will need to look into a POSIX kernel if you want to do anything really fancy
0
 
LVL 20

Expert Comment

by:Gns
ID: 8064175
If it is for below second timing, try
man usleep
try with
time usleep 100000<Enter>

Otherwise describe in more detail what you're after (or rather why;-).

-- Glenn
0
 

Author Comment

by:inudaci
ID: 8064727
startTime=`date +%s`
wget fileaddress
endTime=`date +%s`

downloadTime=$(($endTime-$startTime))

the start/end variables are specified in seconds.
i really need to get that in milliseconds or 1/100 of a second. Do you know how i can achieve this?
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 3

Expert Comment

by:naccad
ID: 8065013
I never did that in bash but you can achive that in perl
using the Time::HiRes Module

use Time::HiRes qw( gettimeofday tv_interval );
my $t0 = [gettimeofday];
`wget fileaddress`;
my $t1 = [gettimeofday];
my $elasped = tv_interval ( $t0, $t1);
print "$elasped\n";

hope that helps.
-nick
0
 

Author Comment

by:inudaci
ID: 8065394
im sure that would work, never installed a pm for perl before though.. i don't know if i wanna go down that path

0
 
LVL 3

Expert Comment

by:naccad
ID: 8065467
u can use the CPAN module for that, its actully easy
if u have a minute give it a try

perl -MCPAN -eshell

install Time::HiRes


it will even guide u thru any needed dependencies
im not even sure that u need to install this one separate or
if it comes with your perl distro

like i said, give it try 1st

tc
-nick
0
 
LVL 9

Accepted Solution

by:
majorwoo earned 40 total points
ID: 8065505


time wget filename

time will do just what it says, time how long the command wget takes -> its much more accurate then using two timestamps
0
 

Author Comment

by:inudaci
ID: 8065776
ok, thanks every one. and thanks for the installing module manual but,
that 'time wget..' is exactly what i was looking for.
0
 

Author Comment

by:inudaci
ID: 8066066
just for the reference.

in the case of wget, the best way to get the actual download time, is not to use time wget. That times the whole process of connecting too. If you only want the actual download time, use download rate calculated with the file size.
0
 
LVL 9

Expert Comment

by:majorwoo
ID: 8066538
hmm, i got a C for "exactly what I was looking for"

what was it you did want then?
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question