Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read JS variable in C# / Forwarding JS variable to visual studio performance test?

People here are using visual studio for performance testing. Now there are some small issues with some javascript parts: they are not able to check the performance of the javascript part with visual studio web-performance testing.

I never used visual studio performance test, so I really have no idea how to bench stuff there, but I saw there are a lot of solutions for web + js performance check. I thought we could use other tools and frameworks, but its not allowed. People here want to use visual studio for everything. So this is making stuff more tricky.

If I would have to check the javascript performance, I would easily do something like this:

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

At the end I can see in the variable bench my result. Now I just have to pass this variable "somehow" to the visual studio performance test? Via C#? Or how is this stuff working? Could this be a good solution? Any other ideas?

like image 689
silla Avatar asked Jan 09 '13 08:01

silla


1 Answers

I don't think it's possible because VS Performance Test Engine doesn't run any client-side code at all, it works on HTTP level only. So the code you provided as an example would never be run.

Take a look here for the proof - 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.

So the only way would be to use other solutions to check javascript performance, or implement your own, based on Selenium for example. I think it's possible to automate such measurements using Selenium RC which can be run from Visual Studio as a part of a build (if your requirement is to use Visual Studio for everything).

like image 127
vladich Avatar answered Oct 03 '22 17:10

vladich