为什么我的AngularJS,噶/茉莉测试运行的这么慢? [英] Why are my AngularJS, Karma / Jasmine tests running so slowly?

查看:225
本文介绍了为什么我的AngularJS,噶/茉莉测试运行的这么慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有针对angularjs应用程序运行一些简单的因果报应/茉莉单元测试。我用的是最新版本的Chrome,并从WebStorm IDE中运行我的测试。

I have some simple karma / jasmine unit-tests that run against an angularjs app. I use the latest version of Chrome and run my tests from within the WebStorm IDE.

有时候测试套件的运行速度很快(0.24秒),

Sometimes the test suite runs very quickly (0.24 seconds)

有时完全相同的测试套件对完全相同的code运行速度非常慢(120秒)

Sometimes exactly the same test suite against exactly the same code runs very slowly (120 seconds)

我已经想尽常识修复。我已经冲刷网页,试图发现什么我做​​错了。

I have tried every common sense fix. I have scoured the web to try and discover what I am doing wrong.

为什么我的测试跑的那么慢?

Why do my tests run so slowly?

推荐答案

答案原来是非常简单的。

The answer turns out to be very simple.

我使用Chrome浏览器运行的业力服务器。当你第一次启动因缘服务器浏览器的一个实例启动为最大化窗口。所以很自然,你尽量减少这种所以你可以看到你的测试运行。

I am using Chrome to run the karma server. When you first start the karma server an instance of Chrome is started as a maximised window. So naturally you minimise this so you can see your tests running.

的问题是,铬饿死CPU周期的任何减少或次级翼片(切换标签)。

The problem is that Chrome starves any minimised or secondary tabs (switched tabs) of CPU cycles.

因此​​,如果您最小化浏览器实例中运行的业力服务器,或者只是切换到不同的选项卡,然后善缘服务器受到严重匮乏CPU和测试需要很长的时间才能完成。

Therefore, if you minimise the browser instance running the karma server, or just switch to a different tab, then the karma server is severely starved of CPU and the tests take a long time to complete.

解决的办法是保持因缘标签活跃。浏览器窗口可以在其他窗口后面被隐藏,但善缘标签的必须是活动的的和浏览器的不能最小化的。

The solution is to keep the karma tab active. The browser window can be hidden behind other windows but the karma tab must be active and the browser must not be minimised.

遵循这些简单的规则将确保您始终测试在全速运行。

Following these simple rules will ensure that your tests always run at full speed.

这篇关于为什么我的AngularJS,噶/茉莉测试运行的这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆