Time in Milisecs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Time in Milisecs

Salvador Alcaraz
Hello everybody, from Spain:
 
This is my first time in the Erlang's Mails List.
 
 My questions is very simple: I need to get time system in Milisec.
 
For example, function erlang:now() return {MegaSecs, Secs, MicroSecs}, but
not Milisec.

Can I use time Milisec with any Erlang's function???

The problem is that I am development a Packet Switching Network Simulator
Tools, and I need to work with Milisec time unit.

Thank you very much.


Salva
_________________________________________________
Salvador Alcaraz Carrasco
Division de Ingenieria Telematica
Dpto. de Fisica y Arquitectura de Computadores
Universidad Miguel Hernandez

salcaraz
http://obelix.umh.es
__________________________________________________



Reply | Threaded
Open this post in threaded view
|

Time in Milisecs

Matthias Lang-2

 >  My questions is very simple: I need to get time system in Milisec.
 >  
 > For example, function erlang:now() return {MegaSecs, Secs, MicroSecs}, but
 > not Milisec.

If you have Megasecs, secs and microsecs, you can derive milliseconds
from that, e.g.

1> MS = fun() -> {Mega, S, Micro} = now(), Mega * 1000000000 + S * 1000 + Micro div 1000 end.
#Fun<erl_eval.19.30196098>
2> MS().
989303156877
3> MS().
989303158117

This is not terribly efficient.

 > Can I use time Milisec with any Erlang's function???

In general, milliseconds are the unit of choice in erlang and its
libraries. For instance, timeouts in receive statements are in
milliseconds. Some exceptions are now() and timer:tc()

 > The problem is that I am development a Packet Switching Network Simulator
 > Tools, and I need to work with Milisec time unit.

People often decouple simulators from real time, i.e. time elapsed in
the simulation is not the same as time elapsed on your wall clock.

Matthias