libgo icon indicating copy to clipboard operation
libgo copied to clipboard

空载延迟达到20us

Open bethebest0622 opened this issue 1 year ago • 4 comments

int main() {
  co_sched.goStart(0);

  timeval t;
  gettimeofday(&t, NULL);

  go [] {}; 

  timeval t2; 
  gettimeofday(&t2, NULL);

  int latency = (t2.tv_sec - t.tv_sec) * 1000000 + (t2.tv_usec - t.tv_usec);

  printf("cost %d\n", latency);

这段代码需要20us,空载的延迟这么高吗

bethebest0622 avatar Jan 27 '24 13:01 bethebest0622

已收到您的邮件,如有问题会尽快给您回复. 

paradiseforgithub avatar Jan 27 '24 13:01 paradiseforgithub

仅仅测试单个耗时极短的函数开销意义不大,毕竟gettimeofday也是有开销的。可以循环运行百万次、千万次以使误差更小。

hnwyllmm avatar Jan 29 '24 01:01 hnwyllmm

image

nqf avatar Jan 30 '24 01:01 nqf

image

可以加个vx聊聊吗

bethebest0622 avatar Jan 30 '24 03:01 bethebest0622