gpt4 book ai didi

c# - 读取 C# 中的 JS 变量/将 JS 变量转发到 visual studio 性能测试?

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:06 26 4
gpt4 key购买 nike

这里的人正在使用 visual studio 进行性能测试。现在一些 javascript 部分存在一些小问题:他们无法使用 visual studio web 性能测试来检查 javascript 部分的性能。

我从来没有用过visual studio performance test,所以我真的不知道如何在那里进行bench stuff,但是我看到有很多web + js performance check的解决方案。我以为我们可以使用其他工具和框架,但不允许。这里的人想用 visual studio 来做所有事情。所以这让事情变得更加棘手。

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

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

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

最佳答案

我认为这是不可能的,因为 VS 性能测试引擎根本不运行任何客户端代码,它仅在 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)。

关于c# - 读取 C# 中的 JS 变量/将 JS 变量转发到 visual studio 性能测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14231421/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com