1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Clock: Update stat. Insert timer to execute first

This commit is contained in:
winlin 2021-02-11 17:34:03 +08:00
parent fb61a6979c
commit 321f555e30
10 changed files with 112 additions and 65 deletions

View file

@ -1,2 +1,4 @@
udp-server
udp-client
cost
cost.log

View file

@ -1,10 +1,11 @@
/*
g++ -g -O0 cost.cpp -o cost && ./cost | grep COST
g++ -g -O0 cost.cpp ../../objs/st/libst.a -I../../objs/st -o cost && ./cost | grep COST
*/
#include <stdio.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <st.h>
#define SRS_UTIME_MILLISECONDS 1000
#define srsu2i(us) ((int)(us))
@ -143,6 +144,18 @@ int main(int argc, char** argv)
);
}
// The cost for ST timer.
st_set_eventsys(ST_EVENTSYS_ALT);
st_init();
for (;;) {
int64_t start = srs_update_system_time();
st_usleep(20 * 1000);
int64_t cost = srs_update_system_time() - start;
if (cost > (20 + 10) * 1000) {
printf("[COST] timer=%dms\n", (int)(cost / 1000));
}
}
return 0;
}