如何在Erlang中获取微秒from now()

klh5stk1  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(205)

我尝试将相应的线程与时间戳(从现在开始的微秒数函数)匹配,就像 *jill从john [739000]收到介绍消息**和john从jill [739000]收到回复消息 *

if
     I == true ->
         M_pid!{lists:concat([Self_name," received intro message from ", Process_name , "[",erlang:now(),"]"]), self()},
         %io:fwrite(I),
         whereis(Process_name)!{Self_name, "reply",self()},
         friends(Msg, M_pid, State + 1, Self_name);
     R == true ->
         M_pid!{lists:concat([Self_name," received reply message from ", Process_name , "[",pid_to_list(Process_id),"]"]), self()},
         friends(Msg, M_pid, State + 1, Self_name)
 end

我试着从process_id改到微秒从now()。我是一个新手到厄兰。提前感谢大家!

ehxuflar

ehxuflar1#

erlang:now() is deprecated and should NOT be used. There are two options to get current time in microseconds

  1. os:timestamp()
{Mega, Sec, Micro} = os:timestamp(),
(Mega * 1000000 + Sec) * 1000000 + Micro.
  1. os:system_time(microseconds)

相关问题