我需要找到Android应用中瓶颈的位置.
我可以使用哪些分析工具或技术?
下面的代码,在.NET 4.5上运行发布配置时,会产生以下输出...
Without virtual: 0.333333333333333
With virtual: 0.333333343267441
Run Code Online (Sandbox Code Playgroud)
(在调试中运行时,两个版本都会给出0.333333343267441结果.)
我可以看到,将一个浮点除以一个short并将其返回一个double可能会在一个点之后产生垃圾.
我的问题是:任何人都能解释为什么在分母中提供短片的属性是虚拟的还是非虚拟的时,结果会有所不同?
public class ProvideThreeVirtually
{
public virtual short Three { get { return 3; } }
}
public class GetThreeVirtually
{
public double OneThird(ProvideThreeVirtually provideThree)
{
return 1.0f / provideThree.Three;
}
}
public class ProvideThree
{
public short Three { get { return 3; } }
}
public class GetThree
{
public double OneThird(ProvideThree provideThree)
{
return 1.0f / provideThree.Three;
}
}
class Program
{
static void Main() …Run Code Online (Sandbox Code Playgroud) 在Java中可以将类注释为@Embeddable或将属性设置为@Embedded.示例代码:
@Embeddable
class A{
...
}
class B{
...
}
@Entity
class Foo {
A a;
@Embedded B b;
}
Run Code Online (Sandbox Code Playgroud)
什么时候喜欢@Embedded和@Embeddable?