forked from netdata-be/libnodave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.pas
executable file
·201 lines (187 loc) · 4.63 KB
/
tests.pas
1
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
unit tests;
interface
uses nodave
{$ifdef WIN32}
, windows
{$endif}
{$ifdef LINUX}
,oldlinux
{$define UNIX_STYLE}
{$endif}
;
procedure readBench(dc:pdaveConnection);
procedure writeBench(dc:pdaveConnection);
procedure wait;
implementation
procedure wait;
begin
writeln('Press return to continue.');
readln;
end;
var
{$ifdef UNIX_STYLE}
t1,t2:timeval;
{$endif}
{$ifdef WIN32}
t1, t2:longint;
{$endif}
usec:double;
procedure readBench(dc:pdaveConnection);
var seconds, thirds, res: longint;
i:integer;
p:PDU;
begin
seconds:=0;thirds:=0;
writeln('Now going to do read benchmark with minimum block length of 1.');
wait;
writeln('running...');
{$ifdef UNIX_STYLE}
gettimeofday(t1);
{$endif}
{$ifdef WIN32}
t1:=getTickCount();
{$endif}
for i:=0 to 99 do begin
daveReadBytes(dc,daveFlags,0,0,1,nil);
if (i mod 10)=0 then begin
write('...',i);
(* fflush(stdout); *)
end;
end;
writeln;
{$ifdef UNIX_STYLE}
gettimeofday(t2);
usec := 1e6 * (t2.sec - t1.sec) + t2.usec - t1.usec;
usec:=usec/1e6;
{$endif}
{$ifdef WIN32 }
t2:=getTickCount();
usec := 0.001*(t2 - t1);
{$endif}
writeln('100 reads ',usec,' seconds. tried repeats: 2nd:',seconds,' 3rds:',thirds);
seconds:=0;thirds:=0;
writeln('Now going to do read benchmark with shurely supported block length 16.');
wait();
writeln('running...');
{$ifdef UNIX_STYLE}
gettimeofday(t1);
{$endif}
{$ifdef WIN32}
t1:=getTickCount();
{$endif}
for i:=0 to 99 do begin
daveReadBytes(dc,daveFlags,0,0,16,nil);
if (i mod 10)=0 then begin
write('...',i);
{ fflush(stdout);}
end;
end;
writeln('');
{$ifdef UNIX_STYLE }
gettimeofday(t2);
usec := 1e6 * (t2.sec - t1.sec) + t2.usec - t1.usec;
usec :=usec/1e6;
{$endif}
{$ifdef WIN32 }
t2:=getTickCount();
usec := 0.001*(t2 - t1);
{$endif}
writeln('100 reads ',usec,' seconds. tried repeats: 2nd:',seconds,' 3rds:',thirds);
seconds:=0;thirds:=0;
writeln('Now going to do read benchmark with 4 variables in a single request.');
wait;
writeln('running...');
{$ifdef UNIX_STYLE}
gettimeofday(t1);
{$endif}
{$ifdef WIN32}
t1:=getTickCount();
{$endif}
for i:=0 to 99 do begin
davePrepareReadRequest(dc, @p);
daveAddVarToReadRequest(@p,daveInputs,0,0,1);
daveAddVarToReadRequest(@p,daveFlags,0,0,1);
daveAddVarToReadRequest(@p,daveFlags,0,10,1);
daveAddVarToReadRequest(@p,daveFlags,0,20,1);
res:=daveExecReadRequest(dc, @p, nil);
if (i mod 10)=0 then begin
writeln('...',i);
{ fflush(stdout); }
end;
end;
writeln('');
{$ifdef UNIX_STYLE}
gettimeofday(t2);
usec := 1e6 * (t2.sec - t1.sec) + t2.usec - t1.usec;
usec :=usec/1e6;
{$endif}
{$ifdef WIN32 }
t2:=getTickCount();
usec := 0.001*(t2 - t1);
{$endif}
writeln('100 reads took %g secs. tried repeats: 2nd:%d 3rd%d',usec,seconds,thirds);
end;
procedure writeBench(dc:pdaveConnection);
var seconds, thirds, res, c: longint;
i:integer;
p:PDU;
begin
seconds:=0;thirds:=0;
writeln('Now going to do write benchmark with minimum block length of 1.');
wait();
writeln('running...');
{$ifdef UNIX_STYLE }
gettimeofday(t1);
{$endif}
{$ifdef WIN32 }
t1:=getTickCount();
{$endif}
for i:=0 to 99 do begin
daveWriteBytes(dc,daveFlags,0,0,1,@c);
if (i mod 10)=0 then begin
writeln('...',i);
{fflush(stdout); }
end;
end;
writeln('');
{$ifdef UNIX_STYLE }
gettimeofday(t2);
usec := 1e6 * (t2.sec - t1.sec) + t2.usec - t1.usec;
usec :=usec/1e6;
{$endif}
{$ifdef WIN32 }
t2:=getTickCount();
usec := 0.001*(t2 - t1);
{$endif}
writeln('100 writes took ',usec,' seconds. tried repeats: 2nd:',seconds,' 3rds:',thirds);
seconds:=0;thirds:=0;
writeln('Now going to do write benchmark with always supported block length 16.');
wait;
writeln('running...');
{$ifdef UNIX_STYLE }
gettimeofday(t1);
{$endif}
{$ifdef WIN32}
t1:=getTickCount();
{$endif}
for i:=0 to 99 do begin
daveWriteBytes(dc,daveFlags,0,0,16,@c);
if (i mod 10)=0 then begin
writeln('...',i);
{ fflush(stdout); }
end;
end;
writeln('');
{$ifdef UNIX_STYLE }
gettimeofday(t2);
usec := 1e6 * (t2.sec - t1.sec) + t2.usec - t1.usec;
usec :=usec/1e6;
{$endif}
{$ifdef WIN32 }
t2:=getTickCount();
usec := 0.001*(t2 - t1);
{$endif}
writeln('100 writes took ',usec,' seconds. tried repeats: 2nd:',seconds,' 3rds:',thirds);
wait;
end;
end.