How to test performance Entity Framework?

3

I want to create mapping with inheritance Person - > Customers, etc.

But I would like to test performance with the 3 types of mapping (TPH, TPT, TPC)

How do I? Anyone had experience to talk which of the 3 becomes easier and faster?

    
asked by anonymous 14.08.2014 / 15:32

3 answers

1

You can use the good old Stop

public void Teste()
{
    Stopwatch sw = Stopwatch.StartNew();
    var pessoas = MeuContexto.Pessoas.ToList();
    sw.Stop();
    Console.WriteLine("Tempo demorado = {0}ms", sw.Elapsed);
}
    
14.08.2014 / 16:26
0

TPH (Table per Hierarchy)

All entities in the hierarchy will be mapped to a single table. So there is no need to joins to retrieve the data, generally having a better performance with respect to TPT.

The downside is data redundancy. Some columns related to specific entity classes may contain null values.

TPT (Table per Type)

Each entity in the class hierarchy is mapped to a different table. So there is a need to when selecting the data, generally performing less than TPH.

Implement if necessary for standardization and design (avoid redundancy). Regarding performance is less than TPH.

TPC (Table per Concrete class)

Each concrete class (which can be instantiated in the class hierarchy) is mapped to a specific table, by looking at the fields of the abstr class.

As you can see, it's not just a performance issue, but the decision by one or another pattern will also depend on your modeling.

To test, I recommend mounting your class hierarchy and using a Stopwatch when accessing data such as @ Luís Deschamps Rudge suggested in his response and using Entity Framework Profile to see what is happening" behind the scenes "in the database and so make the decision as you need it.

    
27.01.2016 / 14:58
-1

Use Visual Studio Analyze, you will be able to find out where you are taking more time in your application, we have solved some performance problems using this.

You go to Analyze in the Menu:

Afteryourapplicationwilldebugtostartcollectingtheinformation,thereyouwillrunthetestsyouwant,whileitcollects.

HowlongyoufinishinStopProfile.

Wait,yourapplicationwillexitthedebugandtheresultwillbegenerated,sojustcheckitout.

    
27.01.2016 / 13:20