performance - c# unit test akward runtime -


I am developing a C # tool in Visual Studio 2013 on Win8.

I just started paying the depts for the unit testing (shame on me;)) on a very easy part:

is a class for geometrical vectors Wanted to check whether the init works below given code.

It was found that the sequence of test methods is very strange: when running from the time of test

  TestCreateNonZeroVertex & lt; 1ms TestCreateZeroVertex 4ms TestModifyVertex & lt; 1ms  

Many times executed in the sequence (to eliminate some of the system's buffering stuff) First consideration: Garbage collector -> Forced GC in tampering (with waiting for finishing) Result: Expansion of time (as expected) but proportional

  testcreateNonZeroVertex 2ms TestCreateZeroVertex TestModifyVertex 2ms  

There is a bit more fact about the 8ms (for 13ms with peaks) TestModifyVertex defacto TestCreateZeroVertex + X, I do not understand this discrepancy. Is it because TestCreateZeroVertex is the first method in TestSuite? If so, it seems like a bug in the test environment for me. (Why is the share of disappointment broken?)

If someone can explain, why is the time so strong, and how can this shift (for compairability) To finish off, I want to be very grateful.

Start of class here:

  Public class vertex {public double X {get; Set; } Public double y [receive; Set; } Receive public double jade { Set; } Public Vertex () {X = 0; Y = 0; Z = 0; } Public Vertex (double x, double y, double z) {X = x; Y = y; Z = z; } ...  

Very easy.

I used some test methods:

  [TestMethod] Public Zero TestCreateZeroVertex () {Vertix v = New Vertex (); Assurance.Arequansal & lt; Double & gt; (0.0, v.X, "X value expected to be zero, is:" + v.x); Assign. Eraqual & lt; Double & gt; (0.0, v.Y, "expected y value to be zero, is:" + v.Y); Responsibility.Arequal & lieutenant; Double & gt; (0.0, VJ., "Z value expected to be zero, is:" + v.z); } [Testimede] Public Zero Test Content Nonzerovatex () {Double X = 1.1, Y = 2.2, z = 3.3; Vertex v = new vertex (X, Y, Z); Assurance.Arequal & lieutenant; Double & gt; (X, vx, "expected x value" + x + "yes, this is:" + v.x); Assurance.Are Aquel & lt; Double & gt; (Y, v.Y, "expected y value" + Y + ", is:" + v.Y); Responsibility.Arequal & lt; Double & gt; (Z, v.z, "expected z value" + z + ", is:" + v.z); } [TestMethod] Public Zero TestModifyVertex () {Double X = 1.1, y = 2.2, z = 3.3; Vertex v = new vertix (); Assurance.Arequansal & lt; Double & gt; (0.0, v.X, "X value expected to be zero, is:" + v.x); Assign. Eraqual & lt; Double & gt; (0.0, v.Y, "expected y value to be zero, is:" + v.Y); Responsibility.Arequal & lieutenant; Double & gt; (0.0, VJ., "Z value expected to be zero, is:" + v.z); V.X = x; V.Y = y; V.Z = z; Assurance.Arequal & lieutenant; Double & gt; (X, vx, "expected x value" + x + "yes, this is:" + v.x); Assurance.Are Aquel & lt; Double & gt; (Y, v.Y, "expected y value" + Y + ", is:" + v.Y); Responsibility.Arequal & lt; Double & gt; (Z, v.z, "expected z value" + z + ", is:" + v.z); }  

When your tests are different VS 2012 The test explorer throws they look less or more overdue periods - Some MSs display the same results as they are all executing them, as shown in the question, although in my case TestModifyVertex a Running for a long time.

Without doing extensive research, I'm loading some class issue here - your code may be or (which is probably the case here, as your example is quite compact) some MSTest (Or any tester you are using) code The following tests may get some benefits from the classes already loaded.

So you can try to run each test separately for comparable results, but I do not think this is a good idea. We have tried to detect the decrease in performance in the same way, but have abandoned many false positive reasons. MSTE is not a suitable device for this.

Depending on your visual studio version, try the test profile to get more information about what is happening.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -