You are here: Home > Fastcode project > Documentation for StrCopy BVTool
StrCopy Benchmark and Validation Tool Documentation
The benchmark calls the function under test a number of times
with the same source and destination PChar pointers.
Then it shortens the strings by one and calls the function a number of times
again. The strings are shortened by inserting zero terminators at the location
of the new string end.
The number of times the StrCopy function is called on the same strings is controlled
by the constants NOOFRUNS1 and NOOFRUNS2.
The benchmark is duplicated in
SubBenchmark1 and SubBenchmark2. SubBenchmark1 is running on strings in the
interval 0-30 characters, and SubBenchmark2 is running on strings in the
interval 30-100 characters.
The maximum string lengths are set by the local
MAXSTRLEN constant. It is currently 100.
The string length were SubBenchmark1
stops and SubBenchmark2 starts is controlled by the constant CROSSOVERLENGTH =
30;
The cpu clock tick
counter is used for measuring the runtime.
The function under test is called
twice in the inner loop to tweak alignment of the source versus destination and
to reduce loop overhead.
The strings are global to secure the same alignment
on every benchmark run.
TicksStart := GetCPUTick;
for I1 := MaxStrLen downto 1 do
begin
Dest[I1] := #0;
Source[I1] := #0;
for I2 :=
1 to NOOFRUNS1 do
begin
StrCopyFunction(Dest, Source);
StrCopyFunction(Source, Dest);
end;
end;
TicksEnd
:= GetCPUTick;
- The strings will be located in the L1 cache always.
- The strings will be aligned the same on every call of the function.
- The branch predictor is not put on hard work because the function is called repeatedly on the same strings.