Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

空载延迟达到20us #309

Open
bethebest0622 opened this issue Jan 27, 2024 · 4 comments
Open

空载延迟达到20us #309

bethebest0622 opened this issue Jan 27, 2024 · 4 comments

Comments

@bethebest0622
Copy link

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,空载的延迟这么高吗

@paradiseforgithub
Copy link

paradiseforgithub commented Jan 27, 2024 via email

@hnwyllmm
Copy link

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

@nqf
Copy link

nqf commented Jan 30, 2024

image

@bethebest0622
Copy link
Author

image

可以加个vx聊聊吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants