@@ -5,7 +5,7 @@ use Test::Deep;
5
5
use Test::More;
6
6
use DBI;
7
7
use DBI::Const::GetInfoType;
8
- use Time::HiRes qw( clock_gettime CLOCK_REALTIME ) ;
8
+ use Time::HiRes;
9
9
use strict;
10
10
11
11
use vars qw( $test_dsn $test_user $test_password) ;
@@ -43,25 +43,25 @@ my $rows;
43
43
my $sth ;
44
44
my ( $a , $b , $c );
45
45
46
- $start = clock_gettime(CLOCK_REALTIME );
46
+ $start = Time::HiRes::gettimeofday( );
47
47
$rows = $dbh -> do(' INSERT INTO async_test VALUES (SLEEP(2), 0, 0)' );
48
- $end = clock_gettime(CLOCK_REALTIME );
48
+ $end = Time::HiRes::gettimeofday( );
49
49
50
50
is $rows , 1;
51
51
ok(($end - $start ) >= 2);
52
52
53
- $start = clock_gettime(CLOCK_REALTIME );
53
+ $start = Time::HiRes::gettimeofday( );
54
54
$rows = $dbh -> do(' INSERT INTO async_test VALUES (SLEEP(2), 0, 0)' , { async => 1 });
55
55
ok defined ($dbh -> mysql_async_ready);
56
- $end = clock_gettime(CLOCK_REALTIME );
56
+ $end = Time::HiRes::gettimeofday( );
57
57
58
58
ok $rows ;
59
59
is $rows , ' 0E0' ;
60
60
61
61
ok(($end - $start ) < 2);
62
62
63
63
sleep 1 until $dbh -> mysql_async_ready;
64
- $end = clock_gettime(CLOCK_REALTIME );
64
+ $end = Time::HiRes::gettimeofday( );
65
65
ok(($end - $start ) >= 2);
66
66
67
67
$rows = $dbh -> mysql_async_result;
@@ -75,17 +75,17 @@ is $rows, 2;
75
75
76
76
$dbh -> do(' DELETE FROM async_test' );
77
77
78
- $start = clock_gettime(CLOCK_REALTIME );
78
+ $start = Time::HiRes::gettimeofday( );
79
79
$rows = $dbh -> do(' INSERT INTO async_test VALUES(SLEEP(2), ?, ?)' , { async => 1 }, 1, 2);
80
- $end = clock_gettime(CLOCK_REALTIME );
80
+ $end = Time::HiRes::gettimeofday( );
81
81
82
82
ok $rows ;
83
83
is $rows , ' 0E0' ;
84
84
85
85
ok(($end - $start ) < 2);
86
86
87
87
sleep 1 until $dbh -> mysql_async_ready;
88
- $end = clock_gettime(CLOCK_REALTIME );
88
+ $end = Time::HiRes::gettimeofday( );
89
89
ok(($end - $start ) >= 2);
90
90
91
91
$rows = $dbh -> mysql_async_result;
@@ -100,23 +100,23 @@ is $c, 2;
100
100
101
101
$sth = $dbh -> prepare(' SELECT SLEEP(2)' );
102
102
ok !defined ($sth -> mysql_async_ready);
103
- $start = clock_gettime(CLOCK_REALTIME );
103
+ $start = Time::HiRes::gettimeofday( );
104
104
ok $sth -> execute;
105
- $end = clock_gettime(CLOCK_REALTIME );
105
+ $end = Time::HiRes::gettimeofday( );
106
106
ok(($end - $start ) >= 2);
107
107
108
108
$sth = $dbh -> prepare(' SELECT SLEEP(2)' , { async => 1 });
109
109
ok !defined ($sth -> mysql_async_ready);
110
- $start = clock_gettime(CLOCK_REALTIME );
110
+ $start = Time::HiRes::gettimeofday( );
111
111
ok $sth -> execute;
112
112
ok defined ($sth -> mysql_async_ready);
113
- $end = clock_gettime(CLOCK_REALTIME );
113
+ $end = Time::HiRes::gettimeofday( );
114
114
ok(($end - $start ) < 2);
115
115
116
116
sleep 1 until $sth -> mysql_async_ready;
117
117
118
118
my $row = $sth -> fetch;
119
- $end = clock_gettime(CLOCK_REALTIME );
119
+ $end = Time::HiRes::gettimeofday( );
120
120
ok $row ;
121
121
is $row -> [0], 0;
122
122
ok(($end - $start ) >= 2);
@@ -132,15 +132,15 @@ ok $dbh->errstr;
132
132
$dbh -> do(' DELETE FROM async_test' );
133
133
134
134
$sth = $dbh -> prepare(' INSERT INTO async_test VALUES(SLEEP(2), ?, ?)' , { async => 1 });
135
- $start = clock_gettime(CLOCK_REALTIME );
135
+ $start = Time::HiRes::gettimeofday( );
136
136
$rows = $sth -> execute(1, 2);
137
- $end = clock_gettime(CLOCK_REALTIME );
137
+ $end = Time::HiRes::gettimeofday( );
138
138
ok(($end - $start ) < 2);
139
139
ok $rows ;
140
140
is $rows , ' 0E0' ;
141
141
142
142
$rows = $sth -> mysql_async_result;
143
- $end = clock_gettime(CLOCK_REALTIME );
143
+ $end = Time::HiRes::gettimeofday( );
144
144
ok(($end - $start ) >= 2);
145
145
is $rows , 1;
146
146
@@ -154,9 +154,9 @@ $sth = $dbh->prepare('INSERT INTO async_test VALUES(SLEEP(2), ?, ?)', { async =
154
154
$rows = $dbh -> do(' INSERT INTO async_test VALUES(SLEEP(2), ?, ?)' , undef , 1, 2);
155
155
is $rows , 1;
156
156
157
- $start = clock_gettime(CLOCK_REALTIME );
157
+ $start = Time::HiRes::gettimeofday( );
158
158
$dbh -> selectrow_array(' SELECT SLEEP(2)' , { async => 1 });
159
- $end = clock_gettime(CLOCK_REALTIME );
159
+ $end = Time::HiRes::gettimeofday( );
160
160
161
161
ok(($end - $start ) >= 2);
162
162
ok !defined ($dbh -> mysql_async_result);
0 commit comments