- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我注意到整套 Jasmine 测试开始花费的时间比我希望的要多,但我不确定是哪些真正导致了延迟。有没有一种方法可以在不单独运行每个测试的情况下找出答案?
最佳答案
基础ConsoleReporter
仅报告所有测试耗时,但如果您查看 source code从中您会发现很容易修改以添加每个规范的耗时。基本上你需要做的是在函数 reportSpecStarting
时记录规范开始的时间。 (就在规范开始运行之前)被调用并输出函数 reportSpecResults
时的差异。 (那是在规范完成运行之后)。
因此,如果您修改了 ConsoleReporter
有了这个,它会输出每个规范的名称及其耗时:
this.reportSpecStarting = function() {
this.specStartingTime = this.now();
};
this.reportSpecResults = function(spec) {
var results = spec.results();
print(results.description + " ");
if (results.skipped) {
yellowStar();
} else if (results.passed()) {
greenDot();
} else {
redF();
}
print(" (" + (this.now() - this.specStartingTime) + "ms)");
newline();
};
关于node.js - 如何判断 Jasmine 中哪些测试花费的时间最多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14030175/
我一直在读一本分配给类(class)的书,它提到数组访问需要 O(1) 时间。我意识到这非常快(也许尽可能快),但是如果您有一个循环必须多次引用它,那么分配一个临时变量以在数组中查找值有什么好处吗?或
我一直试图找出为什么这个查询花了这么长时间。以前,它的执行时间约为 150 毫秒到 200 毫秒,但现在需要 25 秒或更长时间。这是从昨晚到今天之间的事。唯一改变的就是将数据添加到表中。 根据下面的
我有一个 ng repeat 重复数据。 - data.image(src)部分为null,src=null的不再重复。 我用一个简单的 ng-if 解决了它。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我已经被这个问题困扰了一段时间了,我被难住了。 Automapper 需要 4 秒来映射 19 个对象。在我的机器(24GB 内存,3.6Ghz i7)上,该操作应该花费毫秒或纳秒。 这是映射调用。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我在机器 A 上有一个 java 进程通过 TCP 与机器 B 上的 Tomcat 通信。 TCP 连接(只是 syn-syn/ack 交换)始终需要 100 毫秒的数量级,而 ping 请求需要 1
我做了一项任务,从 sqlserver 获取超过 200 万条记录并将它们填充到 Asp.net GridView 中。 问题是,查询需要超过 2 分钟才能获得记录,而我的查询现在已经完全优化。 当我
我希望将 165 秒变成 2:40 而不是 0:2:45 函数需要能够适应秒值的大小。 我知道有无数种方法可以做到这一点,但我正在寻找一种干净的方法来做到这一点,除了 jQuery 之外没有任何外部库
我是一名优秀的程序员,十分优秀!