#ifdef _MSC_VER
start = clock();
ngx_http_dummy_data_parse(ctx, r);
cf->request_processed++;
end = clock();
#else
if ((start = times(&tmsstart)) == (clock_t)-1)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"XX-dummy : Failed to get time");
ngx_http_dummy_data_parse(ctx, r);
cf->request_processed++;
if ((end = times(&tmsend)) == (clock_t)-1)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"XX-dummy : Failed to get time");
#endif
if (end - start > 10) // report if it took more than 1/10MS to perform all the checks
Any comments ? it compiles, links and works, but not sure if the 1/10ms test works the same.
clock() looks simpler, I just googled how to get milliseconds in c++ since the test is about more then 10ms this looks ok to me, what makes GetProcessTimes() work better then clock() in this test ?
It is used in a non-blocking and event driven module so getting time past while the thread is running sounds like its suppose to work.
#ifdef _MSC_VER
start = GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &sysTime, &cpuTime);
ngx_http_dummy_data_parse(ctx, r);
cf->request_processed++;
end = GetProcessTimes(GetCurrentProcess(), &createTime2, &exitTime2, &sysTime2, &cpuTime2);
#else
if ((start = times(&tmsstart)) == (clock_t)-1)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"XX-dummy : Failed to get time");
ngx_http_dummy_data_parse(ctx, r);
cf->request_processed++;
if ((end = times(&tmsend)) == (clock_t)-1)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"XX-dummy : Failed to get time");
#endif
if (end - start > 10)
Compiles and links ok, but still the same question, not sure if the 1/10ms test works the same.
And which codeblock is the best in this case.
Some advice which is better and why would be appreciated.