How to measure memory and CPU NHibernate is using?

35 views
Skip to first unread message

Rafael Lillo

unread,
Jun 12, 2019, 4:41:30 AM6/12/19
to nhibernate-development
Hi,

I create ObjectPool to share StringBuilder in NHibernate and I would like to measure how much memory and CPU is using before and after my change, How to do this?



I made those change based on these article:


I didn't open PR yet

Oskar Berggren

unread,
Jun 12, 2019, 6:38:56 AM6/12/19
to nhibernate-...@googlegroups.com
Well, it would be interesting to see if that improves performance.

As for your question, that's not really a question specific to NHibernate. It seems the question is more related to general profiling. Write some unit test or system test that perform a set amount of work and measure it - run time or using profiling tools. I expect there to be loads of stuff on this on the web so I won't try to repeat it here. Unless you have a more specific question on the subject?

The first link you posted also has this very important comment:
All in all there are some really nice tricks and examples of high-performance code to be found in the Roslyn code base. But the main lesson is that you should never be applying these for the sake of it or because they look clever. They should only be used in conjunction with proper performance testing that identifies the parts of your code that cause it to run slower than your performance goals.

It can of course be a fun exercise to refactor some code, but what you can consider is to try to figure out a test and profile CPU consumption _first_ to find hotspots or identify if something is an actual hotspot before changing the code. Then that same test should reveal if the change improved matters.

Another matter is of course if the performance should be measured on some real-world scenario, or a scenario specifically designed to expose some suspected hotspot. Both has it's uses, but if the latter one becomes very contrived it doesn't really matter in the real world and may potentially actually be harmful.

/Oskar


--

---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nhibernate-development/d8aea672-348e-47ee-9b38-a91b9195ab48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages