这是我成为程序员7年后的第一篇关于堆栈溢出的文章。我有一个非常愚蠢的问题。两者之间哪个更有效? C ++或C#编译器会自动对其进行优化吗?如果是,它将更改为什么?
hadoop --cluster your-hadoop-cluster fs -ls /path/your_hive_table_path/ | grep '/path/your_hive_table_path/' | while read line
do
#Get the update date of hive table
date_str=`echo $line | awk -F'[ ]+' '{print $6}'`
#get the path of hive table
table_path=`echo $line | awk -F'[ ]+' '{print $8}'`
#Get the table name of hive table
table_name=`echo $table_path | awk -F'/' '{print $7}' `
today_date_stamp=`date +%s`
table_date_stamp=`date -d $date_str +%s`
stamp_diff=`expr $today_date_stamp - $table_date_stamp`
#Get the diff days from now
days_diff=`expr $stamp_diff / 86400`
#if diff days is greater than 90, rm and drop.
if [ $days_diff -gt 90 ];then
#remove the hdfs file
hadoop --cluster your-hadoop-cluster fs -rm $table_path
#drop the hive table
hive -e"drop table $table_name"
fi
done
答案 0 :(得分:0)
在C#的发布模式下,它们都编译为相同的IL
.class private auto ansi '<Module>'
{
} // end of class <Module>
.class public auto ansi beforefieldinit C
extends [mscorlib]System.Object
{
// Methods
.method public hidebysig
instance void M (
bool a
) cil managed
{
// Method begins at RVA 0x2050
// Code size 3 (0x3)
.maxstack 8
IL_0000: ldarg.1
IL_0001: pop
IL_0002: ret
} // end of method C::M
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
// Method begins at RVA 0x2054
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method C::.ctor
} // end of class C
在Debug Configuration(调试配置)中,b==a
和// Methods
.method public hidebysig
instance void M (
bool a
) cil managed
{
// Method begins at RVA 0x2050
// Code size 9 (0x9)
.maxstack 1
.locals init (
[0] bool,
[1] bool
)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.1
// sequence point: hidden
IL_0003: ldloc.1
IL_0004: brfalse.s IL_0008
IL_0006: ldarg.1
IL_0007: stloc.0
IL_0008: ret
} // end of method C::M
之间有很小的区别(消除噪声);参见IL_0006行。
// Methods
.method public hidebysig
instance void M (
bool a
) cil managed
{
// Method begins at RVA 0x2050
// Code size 9 (0x9)
.maxstack 1
.locals init (
[0] bool,
[1] bool
)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.1
// sequence point: hidden
IL_0003: ldloc.1
IL_0004: brfalse.s IL_0008
IL_0006: ldc.i4.1
IL_0007: stloc.0
IL_0008: ret
} // end of method C::M
和b == true版本
document.getElementById('button4').addEventListener('click', function(){
document.getElementById('box').style.height = null;
document.getElementById('box').style.background = null;
document.getElementById('box').style.opacity = null;
}
在实践中,在担心这种微观优化之前,我希望先对您的确切用法进行基准测试。花费在优化工作上的时间不可能是最有价值的。