我会简短:
我想测量 C 中的时间跨度,比如在套接字中发送这样的小东西:
sendto (s, buffer, sizeof (buffer), 0, (struct sockaddr *) &peer, peerlen);
我目前正在这样做:
clock_t cBegin = (double)clock () * CLOCKS_PER_SEC;
sendto (s, buffer, sizeof (buffer), 0, (struct sockaddr *) &peer, peerlen);
clock_t cEnd = (double) clock() * CLOCKS_PER_SEC;
elapTicks = cEnd - cBegin;
elapMilli = elapTicks/1000;
printf ("Milisegundos: %lf, %lf\n", cBegin, cEnd);
但我的 printf 总是 0.000000。我应该如何进行?
提前致谢!