-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerformanceTests.dpr
More file actions
87 lines (64 loc) · 2.19 KB
/
PerformanceTests.dpr
File metadata and controls
87 lines (64 loc) · 2.19 KB
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
program PerformanceTests;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Generics.Collections,
System.Classes,
System.Diagnostics,
Neon.Core.Types,
Neon.Core.Persistence.JSON,
Neon.Core.Attributes,
Neon.Core.Persistence,
WiRL.Client.Application,
WiRL.http.Client.NetHttp,
WiRL.http.Client,
WiRL.Client.CustomResource,
WiRL.Client.Resource,
WiRL.Client.Resource.JSON,
Sample in 'Demo\Sample.pas',
Server.Recources.Todos in 'Demo\Server.Recources.Todos.pas',
RestClient.Core.Attributes in 'Source\RestClient.Core.Attributes.pas',
RestClient.Core.Interceptor in 'Source\RestClient.Core.Interceptor.pas',
RestClient.Core.RestCaller in 'Source\RestClient.Core.RestCaller.pas',
RestClient.Core in 'Source\RestClient.Core.pas';
var
I: Integer;
numberOfExecutions: Integer;
sampleRestClient: ISampleRestClient;
todo: TTodo;
restCaller: TRestCaller;
sw: TStopwatch;
sw2: TStopwatch;
begin
try
//My Method
numberOfExecutions := 10000;
Writeln('Number of iterations: ' + IntToStr(numberOfExecutions));
sw := TStopwatch.StartNew;
GlobalRestClient.RegisterClient<ISampleRestClient, TSampleRestClient>;
sampleRestClient := GlobalRestClient.Resolve<ISampleRestClient>;
for I := 0 to numberOfExecutions do begin
todo := sampleRestClient.GetTodo(1);
end;
sw.Stop;
Writeln('My RestClient GET: ', sw.ElapsedMilliseconds / numberOfExecutions, ' ms');
// Standard Method
sw2 := TStopwatch.StartNew;
for I := 0 to numberOfExecutions do begin
restCaller := TRestCaller.Create(nil);
restCaller.SetServerURL('http://localhost:8080/rest/app/v1');
todo := restCaller.DoStandardRestCall('/todos/1', TRestType.GET);
end;
sw2.Stop;
FreeAndNil(restCaller);
FreeAndNil(todo);
//Writeln('My RestClient GET: ', sw.ElapsedMilliseconds / numberOfExecutions, ' ms');
Writeln('Wirl RestClient GET: ', sw2.ElapsedMilliseconds / numberOfExecutions, ' ms');
// Writeln('Difference: ', (sw.ElapsedMilliseconds / numberOfExecutions) - (sw2.ElapsedMilliseconds / numberOfExecutions) , ' ms' );
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.