adding test scripts
[csql.git] / test / performance / perf.php
blob14b54b38b3adb5c201a00e36480d6b21ab94dda9
1 <html>
2 <body>
3 <?php
4 /*Performance Test for all parameterised DML*/
6 //$conn=odbc_connect('myodbc3','root','');
7 $conn=odbc_connect('mycsql','root','manager');
8 if (!$conn)
9 {exit("Connection Failed: " . $conn);}
10 echo "Connection Passed\n";
12 $sth = odbc_prepare($conn,"CREATE TABLE t1 (f1 BIGINT, f2 char(196), primary key (f1));");
13 $res = odbc_execute($sth);
14 if (!$res)
15 {exit("Error in Creation");}
16 echo "Table Created\n";
18 $timecount = 0;
19 $min = 1;
20 $max = 0;
21 $time_start = 0;
22 $time_end = 0;
23 $time = 0;
24 $count =0;
25 $q = "INSERT INTO t1(f1,f2) values(?,?);";
26 $b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9876543210";
27 $res = odbc_prepare ($conn, $q);
28 for ($i = 0; $i <100; $i++)
30 $time_start = microtime();
31 $a = $i;
32 odbc_execute($res, array($a, $b));
33 $time_end = microtime();
34 $time = $time_end - $time_start;
35 $timecount = $timecount + $time ;
36 if ($min > $time)
37 {$min = $time;}
38 if ($max < $time)
39 {$max = $time;}
40 $count++;
42 printf("\nInsert :%6d MIN :%4f MAX :%4f AVG :%4f \n",$count,$min,$max,$timecount/$count);
44 /*$sth = 'SELECT * FROM t1;';
45 $rs = odbc_exec($conn, $sth);
46 if (!$rs)
47 {exit("Error in SQL-2");}
48 odbc_result_all($rs, 'border = 2');
51 $timecount = 0;
52 $min = 1;
53 $max = 0;
54 $time_start = 0;
55 $time_end = 0;
56 $time = 0;
57 $count =0;
58 $q = "SELECT * FROM t1 WHERE f1=?;";
59 $res = odbc_prepare ($conn, $q);
60 for ($i = 0; $i <100; $i++)
62 $time_start = microtime();
63 $a = $i;
64 $rs=odbc_execute($res, array($a));
66 while (odbc_fetch_row($res))
68 //$roll=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($res, 1));
69 $roll=odbc_result($res, 1);
70 //$name=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($res, 2));
71 $name=odbc_result($res, 2);
74 $time_end = microtime();
75 $time = $time_end - $time_start;
76 $timecount = $timecount + $time ;
77 if ($min > $time)
78 {$min = $time;}
79 if ($max < $time)
80 {$max = $time;}
81 $count++;
83 printf("\nSelect :%6d MIN :%4f MAX :%4f AVG :%4f \n",$count,$min,$max,$timecount/$count);
85 $timecount = 0;
86 $min = 1;
87 $max = 0;
88 $time_start = 0;
89 $time_end = 0;
90 $time = 0;
91 $count =0;
92 $q = "update t1 set f2=? where f1=?;";
93 $res = odbc_prepare ($conn, $q);
94 for ($i = 0; $i <100; $i++)
96 $time_start = microtime();
97 $a = "LAKSHYA_CSQL";
98 $b = $i;
99 odbc_execute($res, array($a, $b));
100 $time_end = microtime();
101 $time = $time_end - $time_start;
102 $timecount = $timecount + $time ;
103 if ($min > $time)
104 {$min = $time;}
105 if ($max < $time)
106 {$max = $time;}
107 $count++;
109 printf("\nUpdate :%6d MIN :%4f MAX :%4f AVG :%4f \n",$count,$min,$max,$timecount/$count);
112 $sth = 'SELECT * FROM t1;';
113 $rs = odbc_exec($conn, $sth);
114 if (!$rs)
115 {exit("Error in SQL-2");}
116 odbc_result_all($rs, 'border = 2');
119 $timecount = 0;
120 $min = 1;
121 $max = 0;
122 $time_start = 0;
123 $time_end = 0;
124 $time = 0;
125 $count =0;
126 $q = "DELETE FROM t1 WHERE f1=?;";
127 $res = odbc_prepare ($conn, $q);
128 for ($i = 0; $i <100; $i++)
130 $time_start = microtime();
131 $a = $i;
132 $rs = odbc_execute($res, array($a));
133 $time_end = microtime();
134 $time = $time_end - $time_start;
135 $timecount = $timecount + $time ;
136 if ($min > $time)
137 {$min = $time;}
138 if ($max < $time)
139 {$max = $time;}
140 $count++;
142 printf("\nDelete :%6d MIN :%4f MAX :%4f AVG :%4f \n",$count,$min,$max,$timecount/$count);
145 $sth = 'SELECT * FROM t1;';
146 $rs = odbc_exec($conn, $sth);
147 if (!$rs)
148 {exit("Error in SQL-2");}
149 odbc_result_all($rs, 'border = 2');
152 $sth=odbc_prepare($conn,"DROP TABLE t1;");
153 $res = odbc_execute($sth);
154 if (!$res)
155 {exit("\nError in Drop Table");}
156 echo "\nTable Dropped \nTest Passed";
157 odbc_close($conn);
160 </body>
161 </html>