加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在C#/ Forwarding JS变量中读取JS变量到visual studio性能测试?

发布时间:2020-12-15 08:37:04 所属栏目:百科 来源:网络整理
导读:这里的人们正在使用visual studio进行性能测试.现在一些 javascript部分存在一些小问题:他们无法使用visual studio web-performance测试来检查javascript部分的性能. 我从未使用过visual studio性能测试,所以我真的不知道如何在那里进行测试,但是我看到有很
这里的人们正在使用visual studio进行性能测试.现在一些 javascript部分存在一些小问题:他们无法使用visual studio web-performance测试来检查javascript部分的性能.

我从未使用过visual studio性能测试,所以我真的不知道如何在那里进行测试,但是我看到有很多用于web js性能检查的解决方案.我认为我们可以使用其他工具和框架,但不允许这样做.这里的人们想要将视觉工作室用于一切.所以这让事情变得更加棘手.

如果我必须检查javascript性能,我会很容易做到这样的事情:

var begin = new Date();
functionA();
functionB();
functionX();
var end = new Date();
var bench = end - begin;

最后,我可以在变量工作台中看到我的结果.现在我只需要将这个变量“以某种方式”传递给visual studio性能测试?通过C#?或者这些东西是如何工作的?这是一个很好的解决方案吗?还有其他想法吗?

解决方法

我认为这是不可能的,因为VS Performance Test Engine根本不运行任何客户端代码,它仅适用于HTTP级别.因此,您作为示例提供的代码永远不会运行.

看看这里的证明 – http://msdn.microsoft.com/en-us/library/ff520100.aspx

Because the Web Performance Test Engine works at the HTTP layer,it
does not run client-side scripting like JavaScript or ActiveX
controls. Web Performance Tests are concerned with generating load on
a server.. Therefore,client-side scripting that only affects the
appearance of a Web page is not significant to the Web Performance
Test. Client-side scripting that sets parameter values or results in
additional HTTP requests,such as AJAX,does affect the load on the
server and might require you to manually modify the Web Performance
Test to simulate the scripting.

A common misconception is that because recording occurs in Internet
Explorer,and the Web Performance Test Result Viewer displays results
in a browser control,Web performance tests must somehow execute using
Internet Explorer. This is not the case. All requests are executed
directly using the Web Performance Test Engine; no interaction with
Internet Explorer or any other browser occurs. The Web Performance
Test Engine communicates directly with the target Web server using
standard HTTP request/response messages.

因此,唯一的方法是使用其他解决方案来检查javascript性能,或者基于Selenium实现自己的性能.我认为可以使用Selenium RC自动执行此类测量,Selenium RC可以作为构建的一部分从Visual Studio运行(如果您的要求是将Visual Studio用于所有内容).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读