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

标签 performance asp-classic vbscript

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

在同一页面中,我注意到以前的维护者使用的 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/

相关文章:

session - ASP中如何设置session永不过期

c++ - 有什么方法可以更快地处理 "predictable branches"吗?

ruby-on-rails - 如何为亚马逊 s3 图像添加过期标题?

MySQL IN 条件子查询

if-statement - 如何在 VBScript for Classic-ASP 中执行单行 If 语句?

xml - MICROSOFT.XMLDOM — 选择包含特定节点的节点

javascript - 从浏览器打开文件时出现奇怪的 Javascript/vbscript 行为

java - 我可以尝试哪些 HttpClient 风格可以执行 url 并获取字符串形式的响应?

java - ASP 中的 EOF 和 BOF

asp-classic - 使用经典 ASP 和 VB 脚本对 ZIP 文件进行 Base64 编码