gpt4 book ai didi

performance - 哪种方法会表现更好? (或者差异还不够大吗?)

转载 作者:行者123 更新时间:2023-12-01 10:14:46 26 4
gpt4 key购买 nike

以下哪一项(如果有的话)对性能的影响最小?还是差异如此之小以至于我应该使用最具可读性的?

在同一页面中,我注意到以前的维护者使用的 3 种样式:

方法一:

If (strRqMethod = "Forum" or strRqMethod = "URL" or strRqMethod = "EditURL" or strRqMethod = "EditForum") Then
...
End If

方法二:

Select Case strRqMethod
Case "Reply", "ReplyQuote", "TopicQuote"
'This is the only case in this statement...'
...
End Select

方法三:

If InArray("Edit,EditTopic,Reply,ReplyQuote,Topic,TopicQuote",strRqMethod) Then
...
End If

.
.
.

'Elsewhere in the code'
function InArray(strArray,strValue)
if strArray <> "" and strArray <> "0" then
if (instr("," & strArray & "," ,"," & strValue & ",") > 0) then
InArray = True
else
InArray = False
end if
else
InArray = False
end if
end function

远离经典 ASP/VBScript 不是一种选择,因此这些评论无需费心发布。

最佳答案

您可以自己进行基准测试以获得最佳结果,因为某些性能会因输入字符串的大小而异。

但是,从维护的角度来看,第二个更容易阅读/理解。

关于performance - 哪种方法会表现更好? (或者差异还不够大吗?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2195616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com