![](https://www.cnblogs.com/images/cnblogs_com/flyfire/51837/r_%e6%9c%aa%e5%91%bd%e5%90%8d.bmp)
因此在以前脚本上加入了一个System.DateTime.Now的访问方法来测试程序运行的速度:
1
using System.Data
2![](/Images/OutliningIndicators/None.gif)
3
function TestSpeed(t_rowNum,t_column)
4
{
5
start=System.DateTime.Now
6
/*
7
加入了测试字符串中加入表达式的功能
8
字符串的功能还有待完善
9
*/
10![](/Images/OutliningIndicators/InBlock.gif)
11
print("OK le ")
12![](/Images/OutliningIndicators/InBlock.gif)
13
loadLib("C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll")
14
a=new DataTable()
15
c1 =new DataColumn("c1")
16
a.Columns.Add(c1)
17![](/Images/OutliningIndicators/InBlock.gif)
18
c2 =new DataColumn("c2")
19
a.Columns.Add(c2)
20![](/Images/OutliningIndicators/InBlock.gif)
21![](/Images/OutliningIndicators/InBlock.gif)
22
//----设置行数和列数,现在用函数来表示就不需要了
23
//t_rowNum = 1000 //行数
24
//t_column = 50 //列数
25![](/Images/OutliningIndicators/InBlock.gif)
26![](/Images/OutliningIndicators/InBlock.gif)
27![](/Images/OutliningIndicators/InBlock.gif)
28
c3 =new DataColumn("c3")
29
a.Columns.Add(c3)
30
for(cc = 4 ;cc<50;cc=cc+1)
31
{ //增加列
32
a.Columns.Add(new DataColumn("c"+cc))
33
}
34
print "运行一个<%t_rowNum%>行<%t_column%>的表,测试需要多少时间"
35
for(rr = 0 ;rr<1000;rr=rr+1)
36
{
37![](/Images/OutliningIndicators/InBlock.gif)
38
b=a.NewRow()
39
for(cc = 0 ;cc<a.Columns.Count;cc=cc+1)
40
{ //增加列
41
b[cc]="ni hao "+cc+":"+rr
42
}
43![](/Images/OutliningIndicators/InBlock.gif)
44
//print("生成了一行")
45
a.Rows.Add(b)
46
// print("增加了一行")
47![](/Images/OutliningIndicators/InBlock.gif)
48
}
49
PrintTable(a)
50
end =System.DateTime.Now //结束时间
51![](/Images/OutliningIndicators/InBlock.gif)
52
///------------------------打印结果
53
print "程序已经运行了:"+(end-start).TotalSeconds+"秒"
54
} // TestSpeed结束了
55
56
57
58
////-----函数打印表格
59
function PrintTable(table)
60
{
61
62
//print("表一共有"+a.Rows.Count+"行")
63
for(i=0;i<a.Rows.Count;i=i+1)
64
{
65
// print(a.Rows[i])
66
for(j=0;j<a.Columns.Count;j=j+1)
67
{
68
69
// print("列"+i+","+j)
70
// print("这是字符串中的运算a.Rows[i][j]:<%a.Rows[i][j]%>定义了 ")
71
// print(a.Rows[i][j])
72
//print("使用列名来访问")
73
//print a.Columns[j].ColumnName
74
// print(a.Rows[i][a.Columns[j].ColumnName])
75
}
76![](/Images/OutliningIndicators/InBlock.gif)
77
}
78![](/Images/OutliningIndicators/InBlock.gif)
79
80
}
81![](/Images/OutliningIndicators/None.gif)
82
,程序执行的结果如下图所示:![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
55
![](/Images/OutliningIndicators/None.gif)
56
![](/Images/OutliningIndicators/None.gif)
57
![](/Images/OutliningIndicators/None.gif)
58
![](/Images/OutliningIndicators/None.gif)
59
![](/Images/OutliningIndicators/None.gif)
60
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/InBlock.gif)
72
![](/Images/OutliningIndicators/InBlock.gif)
73
![](/Images/OutliningIndicators/InBlock.gif)
74
![](/Images/OutliningIndicators/InBlock.gif)
75
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
76
![](/Images/OutliningIndicators/InBlock.gif)
77
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
78
![](/Images/OutliningIndicators/InBlock.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
81
![](/Images/OutliningIndicators/None.gif)
82
![](/Images/OutliningIndicators/None.gif)