Skip to content

app using 100% of 1 CPU, but not in wxTimer function #137

Description

@davekimble2

I have a wxPHP app which refreshes its window every minute.
(It is tailing an Apache log on another machine on the LAN,
and also checking that the WAN can see my server by bouncing a request off a remote web server.)
It seems to be using 100% of 1 of 4 CPU cores, that is, 25% of the CPU load as reported by LxTask,
or 99% of 1 core as reported by "top".

So I created a simple script:

<?php
$frame = new wxFrame(null, wxID_TOP, "Test");
$frame->Maximize();
$frame->Show();
$timer = new wxTimer();
$timer->Start(5000);
$timer->Connect(wxEVT_TIMER, array(wxID_TOP, "refresh"));
wxEntry();
function refresh() 
{   $start = microtime(true);
    // do nothing
    $end = microtime(true);
    print ($end - $start)." seconds\n";
}
?>

and that takes 2 - 4 microseconds, and 0% of CPU time, as expected.

So I put that into my app's refresh() function,
and it says it only spends 1.5 seconds inside the function every minute.
It would be OK if I was seeing a 1.5 second burst of activity every minute in LxTask, but I'm not.

Where could all that extra CPU time be going?
Any suggestions?

Activity

  1. davekimble2 commented on Jan 21, 2016

    @davekimble2
    Author

    I have just discovered another of my wxPHP apps, that simply displays a table of mathematical and Greek letter symbols and copies them to the clipboard when clicked, is using 80% of one CPU in doing absolutely nothing except waiting for clicks. It is not related to whether its window is in xorg's visible rendering, but if the window is minimised (whether visible or not) the CPU usage goes to zero.

    Lubuntu 14.04, so Openbox window manager.

  2. jgmdev commented on Jan 21, 2016

    @jgmdev
    Member

    Thats strange, are your applications doing some kind of constant drawing?

  3. davekimble2 commented on Jan 21, 2016

    @davekimble2
    Author

    No, but one that does doesn't show the same CPU usage, even when maximized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions