java调用函数影响性能吗,嵌套函数或方法调用会降低应用程序的性能

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?

解决方案

In Java

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值