frequent console.log calls result in 100% cpu and hanging #212

Closed
vaeroon opened this Issue May 15, 2013 · 6 comments

Comments

Projects
None yet
5 participants

vaeroon commented May 15, 2013

I am not sure whats happening here. I wanted to test out the performance of testem (when running the tests in phantomjs in dev mode). I added a couple of for-loops to see the effect. Here is the test that I am trying to execute:

describe('hello', function(){
    it('should say hello', function(){
        for(var i=0; i<100; i++){
          for(var j=0; j<100; j++){
            console.log("hello ", i, " ", j, " ", (i*j));
          }
        }
        expect(hello()).toBe('hello world');
    });

    it('should say hello to person', function(){
        for(var i=0; i<100; i++){
          for(var j=0; j<100; j++){
            console.log("hello ", i, " ", j, " ", (i*j));
          }
        }
        expect(hello('Bob')).toBe('hello Bob');
    });
});

I tried this multiple times. The consistent result is that the process (testem) hangs. I have a 2-core cpu. One of the cores gets continously maxed-out at 100%. The system monitor clearly shows the NodeJS process to be consuming the cpu. PhantomJS also seems to be consuming significant memory (a few hundreds of Megs). Eventually I have to manually kill both the processes (NodeJS, PhantomJS).

I am really not sure whats going on here. To compare I took the same for-loops and executed them directly under NodeJS. It runs in under a couple of secs without even a blip to cpu/memory.

Collaborator

airportyh commented May 16, 2013

I think it's due to the console.log messages being passed through and then the UI having to frequently update. This would be good to fix.

vaeroon commented May 17, 2013

I guess Issue #139 might be related (or same root cause)

tdesmet commented Jun 17, 2014

I had somehow the same problem with a large project where my colleague accidentally left a few console.logs. The tests would run fast in chrome and finish in around 30 seconds. But in the console it took testem around 10 seconds to update that a new test had finished running. So while the browser was done running the 200 + tests after 5 minutes testem was still saying it only ran the first 40 or something. Removing all the log statements resolved this.

It does seem to be a windows issue, since my colleague didn't have this problem on his mac.

Owner

johanneswuerbach commented Feb 3, 2015

The issue should be fixed by: airportyh#453

Contributor

jreading commented Jan 29, 2016

FWIW, I am having this problem. We have tons of deprecation warnings in one app and about 80 tests. Everything eventually grinds to a halt.

Owner

johanneswuerbach commented Jan 29, 2016

Mind creating a new issue with more details (browser, node version, etc.)? Thank you :-)

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