
因此在以前脚本上加入了一个System.DateTime.Now的访问方法来测试程序运行的速度:
1
using System.Data
2
3
function TestSpeed(t_rowNum,t_column)
4
{
5
start=System.DateTime.Now
6
/*
7
加入了测试字符串中加入表达式的功能
8
字符串的功能还有待完善
9
*/
10
11
print("OK le ")
12
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
18
c2 =new DataColumn("c2")
19
a.Columns.Add(c2)
20
21
22
//----设置行数和列数,现在用函数来表示就不需要了
23
//t_rowNum = 1000 //行数
24
//t_column = 50 //列数
25
26
27
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
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
44
//print("生成了一行")
45
a.Rows.Add(b)
46
// print("增加了一行")
47
48
}
49
PrintTable(a)
50
end =System.DateTime.Now //结束时间
51
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
77
}
78
79
80
}
81
82
,程序执行的结果如下图所示:
2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82
