can nested function or method call reduce performance of application


I am developing application using asp.net and C# in which our project architecture has lot of nested function calls.

public Employe GetEmployeOrder(orderid, employe){ GetEmployeOrderWithDetails(orderid, employe.ShippingId,BillingId); } public Employe GetEmployeOrderWithDetails(guid orderid,guid ShippingId,guid BillingId) { // Another function call }

You might have got an idea what scenario I am talking about. If I have such nested calls then is it going to affect performance of my application?


<h2>In Java</h2>

There is little direct effect. Simple methods of between 35 and 325 bytes of byte code get inlined so they don't impact performance. Small methods of 35 bytes are inlined almost immediately and "frequently" called method of up to 325 bytes are inlined by default (This can be increased).

Where you run into problems is if more code is harder to reason about. Code which is harder to reason about, is hard for the developer to optimise (and the JIT in some cases) e.g. say you compute an expensive argument which the nested, nested, nested caller discards. Another common performance problem is transformations e.g. a String is parsed into a double which is converted into a String, into a BigDecimal and finally a String again. If you didn't have some many levels of nested it would be more obvious that what starts as a String could stay a String.

As is usually the case, if in doubt assume the simplest, clearest code is best.


Simply - yes

You should keep your code as straight as possible, each nested function call is creating load on program memory stack - processor is remembering where to jump back, and what to bring back, also not finished functions are remembered on stack.

Simpler? - recurrence loop over and over may lead to funny things, but still, less than 20 levels or recurrences are almost invisible.


  • How to take data from json object…?
  • Why SQL functions are faster than UDF
  • Why is a C++ Hello World binary larger than the equivalent C binary?
  • Is there any way to prepare a struct for future additions?
  • C# automatic property
  • C++ exception safety paranoia: how much is too much?
  • Buffer a large file; BufferedInputStream limited to 2gb; Arrays limited to 2^31 bytes
  • openssl handshake failed
  • How many Vertica Databases can run on a Host in the same time?
  • Vigenere cipher not working
  • How can we prepend rows to a react native list-view?
  • Can I use AllJoyn Framework for Wifi Direct in iOS?
  • MySQL performance when updating row with FK
  • Getting NullPointer exception with File.listfiles()
  • Can I read an iPhone beacon with Windows.Devices.Bluetooth.Advertisement.BluetoothLEManufacturerData
  • Sending keystrokes/mouse clicks to a Java program with Autohotkey
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • SharedPreferences or SQLite Database?
  • Hardware Accelerated Image Scaling in windows using C++
  • copying resource to sdcard gives a damaged file in android
  • Row Count Is Returning the incorrect number using RaptureXML
  • Refering to the class itself from within a class mehod in Objective C
  • Spark fat jar to run multiple versions on YARN
  • How to do unit test for HttpContext.Current.Server.MapPath
  • Using $this when not in object context
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Uncaught Error: Could not find module `ember-load-initializers`
  • Azure Cloud Service Web Role web pages do not load
  • swift auto completion not working in Xcode6-Beta
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • How do you troubleshoot character encoding problems?
  • Cannot Parse HTML Data Using Android / JSOUP
  • Acquiring multiple attributes from .xml file in c#
  • C# - Getting references of reference
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • Is it possible to post an object from jquery to bottle.py?
  • Programmatically clearing map cache
  • java string with new operator and a literal