?? ttys_time.c
字號:
#include "cmd.h"#include "tty.h"#include "ctrl.h"#include <sys/poll.h>#include <sys/time.h>#include <time.h>char cmd = RV;int fd;char rbuf[4];int main() { struct timeval tv, tvo; double t; // init ttys fd = ttys_init(0); // init ctrl ctrl_init(fd); gettimeofday(&tvo, NULL); if (write(fd, &cmd, 1) != 1) { fprintf(stderr, "write error\n"); return -1; } struct pollfd ufds = {fd, POLLIN}; int n; int i = 0; for (; i<300; ++i) { if (poll(&ufds, 1, -1) <= 0) { fprintf(stderr, "poll error\n"); return -1; } if ((n = read(fd, rbuf, sizeof(rbuf))) <= 0) { fprintf(stderr, "read error\n"); return -1; } gettimeofday(&tv, NULL); t = tv.tv_sec - tvo.tv_sec; t += (double)(tv.tv_usec - tvo.tv_usec) / 1e6; tvo = tv; printf("%d\t%f\n", n, t); if (write(fd, &cmd, 1) != 1) { fprintf(stderr, "write error\n"); return -1; } } return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -