How to profile a single library solution using Visual Studio 2008 tool (s)?

I read and practiced the MSDN Profiler Tutorial . But I could not find a way to profile the library solution (the "Run with profile" button is disabled for libraries).

  • The only solution I could think of was to create an executable project just for profiling purposes.
  • I already wrote unit tests for my library using the Visual Studio Team System Test Test Framework, so I guess I can use them for a profile like Rick Minerich does with NUnit.

Can anyone point me in the right direction?

+3
source share
5

, . , , . , , , .

NUnit, . . nunit.exe /include, :

nunit-console myassembly.dll /include:Profile

Analyize- > Performance Wizard. dll , nunit-console, .

, ReSharper Visual Studio . " TESTNAME". , , , .

, , . .

+4

- , , , , .

, - exe, . DLL, , .

0

. Visual Studio , , . , , , .

, ? Visual Studio ​​ ?

: , .

0

By default, all projects must have a software test. This is a simpler mode for implementing code. Now you have to think about embracing all the features of the recordings. He will also use coverage tools.

0
source

In fact, you can add any executable file to the list of targets (right-click on Targets).

The text of Program.cs is pretty simple:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            YourDllLibrary.Tests.TestClass t = new YourDllLibrary.Tests.TestClass();
            t.Init();
            MethodInfo[] m = t.GetType().GetMethods();
            for (int i = 0; i < m.Length; i++)
            {
                MethodInfo mi = m[i];

                if (mi.DeclaringType.Name != t.GetType().Name )
                    continue;

                if(Attribute.GetCustomAttribute(mi, 
                    typeof(Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute)) == null)
                    continue;

                try
                {
                    Console.Write(mi.Name + " - ");
                    mi.Invoke(t, null);
                    Console.WriteLine("passed");
                }
                catch
                {
                    Console.WriteLine("failed");
                }
            }
        }

    }
}
0
source

Source: https://habr.com/ru/post/1703819/


All Articles