从现在的了解来看,TC还不能算是编程语言,基本就是一个简单脚本化工具。
好像必须是有界面运行的。
代码必须加在于定义的函数中
TC所有的语法都是由语句来构成的,这里包含了:
预定义语句: #include "c: //anothercode.txt"
命名空间定义语句: 空间 命名空间名称
函数定义语句: 功能 整型 函数名称()
变量定义语句: 字符型 help
赋值语句: help="给变量赋予的一个值"
函数调用语句: 辅助.消息框(help)
流程控制语句: 这里包含(if语句,while语句,repeat语句,break和continue语句):
函数返回语句: 返回 0
功能结束 函数定义结束语句
空间结束 命名空间定义结束语句
这上面就是TC所有的语句,
下面是测试程序,简单循环100w次。加在init事件中
足足运行了3687ms
对于aau的1亿次1900 ms,简直没法比(怀疑是编译器进行了优化),
这才是真正的脚本速度吧
对比perl,1000w次循环为13s,100w次为1326ms。数量级是差不多的。
对比C,1亿次循环为3s.和aau差不多
对比VB,1亿次循环为2187ms
可见对于这类简单操作,编译和解释语言的速度差距还是比较大的。
namespace perftc1
//定义默认空间
function bool start_click()
//这里添加你要执行的代码
return true
//函数返回语句
endfunction
function bool exit_click()
//这里添加你要执行的代码
help.exit()
return true
//函数返回语句
endfunction
function bool init()
//这里添加你要执行的代码
int a1
int t1
int t2
t1=system.gettickcount()
repeat(1000000)
a1 = a1+1
endrepeat
t2=system.gettickcount()
help.messagebox(convert.inttostr(t2-t1))
return true
endfunction
endnamespace
//空间结束语句
对应的perl程序
#!/usr/local/bin/perl
use strict;
use Time::HiRes qw(time);
my $t=time();
my $a=1;
for (my $i=0;$i<1000000;$i++){
$a=$a+1;
}
my $t1=time();
my $t2=$t1-$t;
print ("$t2.\n");
对比的c程序(我手头的机器没有装Vc, 这个是sun T5140上的,主频1.2G,吃点亏)
#include <stdio.h>
#include <time.h>
main(){
int i,j,k;
time_t time1,time2;
time1= time(NULL);
for(i=0;i<100000000;i++){
j=i;
}
time2= time(NULL);
k=time2-time1;
printf("%d,%d",j,k);
}
对比vb6的(笔记本 2.5G双核)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
Dim j As Integer
Dim i As Integer
Dim k As Integer
Dim t1 As Long
Dim t2 As Long
t1 = GetTickCount
For j = 0 To 10000
For k = 0 To 10000
i = j + k
Next k
Next j
t2 = GetTickCount
MsgBox t2 - t1
End Sub