first,my english is very bad... this is my code:
ev_timer_init(&m_netmsgpoptimer, netMsgTimer_cb, 10, 10.);
ev_timer_start(m_loop, &m_netmsgpoptimer);
m_mainlooptimer.data = (void*)this;
//
ev_timer_init(&m_mainlooptimer, mainloopTimer_cb, 20, 20.);
ev_timer_start(m_loop, &m_mainlooptimer);
ev_loop(m_loop, 0);
and this is perf said:
5504.368980 task-clock # 0.999 CPUs utilized
the perf cpu-clock record like this:
+ 30.08% huhuGame [kernel.kallsyms] [k] mutex_lock ◆
+ 29.40% huhuGame [kernel.kallsyms] [k] memcpy ▒
+ 4.75% huhuGame [kernel.kallsyms] [k] system_call_after_swapgs ▒
if i changed my code line "ev_loop(m_loop, 0)" to this:
timespec _tstart, _tend;
while(!m_bExit)
{
clock_gettime(CLOCK_REALTIME, &_tstart);
ev_loop(m_loop, EVLOOP_ONESHOT);
clock_gettime(CLOCK_REALTIME, &_tend);
long long t1, t2;
t1 = _tstart.tv_sec*10000+_tstart.tv_nsec/100000;
t2 = _tend.tv_sec*10000 + _tend.tv_nsec/100000;
t1 = (t2 - t1)*10;
if(t1 < 100)
usleep(100-t1);
}
cpu utiluze is low.. and why ev_loop(m_loop,0) with ev_time will cost 100% cpu performance?
any answer is helpful,thanks!