views:

18

answers:

1

We are attepting to profile our NHibernate application using NHProf. We have a series of unit tests which exercise various calls. However, if we run the unit test multiple times, we get differing results in NHProf:

  • Session 1 [1]
  • Session 2 [32]
  • Session 3 [32]
  • Session 4 [2]
  • Session 5 [2]

I've tried calling session.Clear() at the end of the unit test, and tried rebuilding the solution. But basically we're wanting to tweak and tune the queries, and can't do that if NHibernate is caching between runs. Surely others have run into this before and we're just being dense, but I'd appreciate any help you can provide.

Update Ok, if that's the expected behavior, how does one go about testing optimizations to queries?

+1  A: 

Here's how to clear the cache completely: http://sessionfactory.blogspot.com/2010/08/clearing-second-level-cache.html

Diego Mijelshon