{"id":126,"date":"2007-02-04T01:17:00","date_gmt":"2007-02-04T01:17:00","guid":{"rendered":"http:\/\/blog.trungson.com\/?p=126"},"modified":"2007-02-04T01:17:00","modified_gmt":"2007-02-04T01:17:00","slug":"usleep-cpu-usage","status":"publish","type":"post","link":"http:\/\/blog.trungson.com\/?p=126","title":{"rendered":"usleep &amp; CPU usage"},"content":{"rendered":"<p>If you&#8217;re making a PHP client-server script using a loop to capture events and process data. The CPU usage might be significant. In our test environment, it consumes 50% CPU cycles constantly. A quick and simple fix: add usleep() of about 100-500ms before looping again so it&#8217;s still interactive with users yet allow CPU to do something else useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re making a PHP client-server script using a loop to capture events and process data. The CPU usage might be significant. In our test environment, it consumes 50% CPU cycles constantly. A quick and simple fix: add usleep() of about 100-500ms before looping again so it&#8217;s still interactive with users yet allow CPU to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts\/126"}],"collection":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126"}],"version-history":[{"count":0,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}