question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Measure performance for overriden methods

See original GitHub issue

Hi. I have following scenario.

class Parent
{
[Time]
virtual SomeMethod()
}

In some cases I need to override SomeMethod as below and measure performance.

class Child:Parent
{
[Time]
override SomeMethod()
}

How can I only keep only overriden method’s performance data.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GeertvanHorrikcommented, Oct 18, 2021

About 2: yes, you can create your own implementation and keep track of the calls that were recently made (e.g. a number of last 10 items). But if I am using MethodTimer, I am interested in both the overridden and base implementation behavior (timing).

If you are only interested in the “overall” time of the method, you could create a non-virtual method that you time, and don’t time the virtual and overridden method. In this case you will always get the “total time”, no matter whether it was overridden or not.

0reactions
eshrefcommented, Oct 18, 2021
  1. It is required.
  2. public static void Log(MethodBase methodBase, TimeSpan elapsed) you mean we can somehow check inside this method that methodBase was overriden and base call performed?
Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance of Overriding vs. if-statement - java
A class which does nothing; A subclass that is doing the output ; Is the Java lookup of the method to call faster...
Read more >
measure(_:) | Apple Developer Documentation
Override defaultPerformanceMetrics to change the default metrics measured by this method. Note. This method starts and stops performance measurement ...
Read more >
Increasing Performance by Reducing Dynamic Dispatch
The dynamic calls are necessary because a subclass of ParticleModel might override point or velocity with a computed property or override ...
Read more >
Measure Java Performance - Sampling or Instrumentation?
It turns out there are actually a few established methods for measuring by adding measurement code: Manually add some System.out.println code for important ......
Read more >
Boosting Performance With Sealed Classes in .NET
Let's see how sealed classes help us in boosting performance in C# ... Again, we inherit from the Animal class and override the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found