- Rexx 教程
- Rexx - 首页
- Rexx - 概述
- Rexx - 环境
- Rexx - 安装
- Rexx - 插件安装
- Rexx - 基本语法
- Rexx - 数据类型
- Rexx - 变量
- Rexx - 运算符
- Rexx - 数组
- Rexx - 循环
- Rexx - 决策
- Rexx - 数字
- Rexx - 字符串
- Rexx - 函数
- Rexx - 栈
- Rexx - 文件 I/O
- Rexx - 文件函数
- Rexx - 子程序
- Rexx - 内置函数
- Rexx - 系统命令
- Rexx - XML
- Rexx - Regina
- Rexx - 解析
- Rexx - 信号
- Rexx - 调试
- Rexx - 错误处理
- Rexx - 面向对象
- Rexx - 可移植性
- Rexx - 扩展函数
- Rexx - 指令
- Rexx - 实现
- Rexx - Netrexx
- Rexx - Brexx
- Rexx - 数据库
- 手持式和嵌入式
- Rexx - 性能
- Rexx - 最佳编程实践
- Rexx - 图形用户界面
- Rexx - Reginald
- Rexx - Web 编程
- Rexx 有用资源
- Rexx - 快速指南
- Rexx - 有用资源
- Rexx - 讨论
Rexx - 性能
任何编程语言的关键方面之一是应用程序的性能。需要特别注意以确保应用程序的性能不受影响。让我们看看为更好地理解而分步骤描述的一些注意事项:
步骤 1 - 尝试减少指令数量 - 在 Rexx 中,每个指令都会产生开销。因此,尝试减少程序中的指令数量。下面显示了可以重新设计的指令示例。
与其使用多个 if else 语句,不如使用 parse 语句。因此,在以下程序中,与其为每个值设置 if 条件,并获取 word1、word2、word3 和 word4 的值,不如使用 parse 语句。
/* Main program */ parse value 'This is a Tutorial' with word1 word2 word3 word4 say "'"word1"'" say "'"word2"'" say "'"word3"'" say "'"word4"'"
步骤 2 - 尝试将多个语句合并为一个语句。下面显示了一个示例。
假设您有以下代码,它为 a 和 b 赋值并将它们传递给名为 proc 的方法。
do i = 1 to 100 a = 0 b = 1 call proc a,b end
您可以轻松地使用 parse 语句将上面给出的代码替换为以下代码。
do i = 1 for 100 parse value 0 1 with a, b, call proc a,b end
步骤 3 - 尽可能用 do..for 循环 替换 do..to 循环。当控制变量在循环中迭代时,通常建议这样做。
/* Main program */ do i = 1 to 10 say i end
上面程序应替换为以下程序。
/* Main program */ do i = 1 for 10 say i end
步骤 4 - 如果可能,从 do 循环中删除 for 条件,如下面的程序所示。如果不需要控制变量,则只需在 do 循环中放入结束值,如下所示。
/* Main program */ do 10 say hello end
步骤 5 - 在 select 子句 中,您认为将被评估的最佳条件需要放在 when 子句 中的第一个位置。因此,在以下示例中,如果我们知道 1 是最频繁的选项,我们将 when 1 子句 作为 select 语句中的第一个子句。
/* Main program */ select when 1 then say'1' when 2 then say'2' otherwise say '3' end
广告