Love Spky's and Star's (never knew you could pass procedures like that)
SCAR Code:
program PxlBench;
const
TotalScans = 10;
BenchString = 'Hello World';
var
MaxW, w, x, y, sx, sy, image, font, InitTime, AvgRate, TotPix, TotTime: integer;
begin
ClearDebug;
DisplayDebugImgWindow(408, 84);
MaxW := TotalScans;
if(TotalScans <= 0)then MaxW := 1;
for w := 1 to MaxW do
begin
font := LoadCharsFromFont2('Arial', 4 * W, false, false, false, false);
image := CreateBitmapMaskFromText(BenchString, font);
GetBitmapSize(image, sx, sy);
InitTime := GetSystemTime;
for x := 1 to sx - 1 do
for y := 1 to sy - 1 do
begin
if(FastGetPixel(image, x, y) = 0)then
FastSetPixel(image, x, y, HSLtoColor(W * (255 / MaxW), 150, 150))
else
FastSetPixel(image, x, y, HSLtoColor(W * (255 / MaxW), X * (255 / sx), Y * (255 / sy)));
CopyCanvas(GetBitmapCanvas(image), GetDebugCanvas, 1, 1, sx, sy, 1, 1, 408, 84);
end;
Writeln('Scan ' + IntToStr(W) + '/' + IntToStr(MaxW) + ': Processed ' + IntToStr((sx - 1) * (sy - 1)) + ' pixels at a rate of ' + IntToStr(Round(((sx - 1) * (sy - 1)) / ((GetSystemTime - InitTime) / 1000.0))) + ' Px/Sec');
TotTime := TotTime + (GetSystemTime - InitTime);
AvgRate := AvgRate + Round(((sx - 1) * (sy - 1)) / ((GetSystemTime - InitTime) / 1000.0));
TotPix := TotPix + ((sx - 1) * (sy - 1));
ClearReport;
AddToReport('Average Px/Sec: ' + IntToStr(AvgRate / W));
FreeBitmap(image);
wait(1000);
end;
ClearReport;
Writeln('String Benchmarked: ' + BenchString);
Writeln('Average Px/Sec: ' + IntToStr(AvgRate / MaxW));
Writeln('Total Pixels processed: ' + IntToStr(TotPix));
Writeln('Total time taken: ' + FloatToStr(TotTime / 1000.0) + ' seconds');
end.
Code:
Scan 1/5: Processed 130 pixels at a rate of 640 Px/Sec
Scan 2/5: Processed 689 pixels at a rate of 958 Px/Sec
Scan 3/5: Processed 1343 pixels at a rate of 1048 Px/Sec
Scan 4/5: Processed 2438 pixels at a rate of 1209 Px/Sec
Scan 5/5: Processed 4371 pixels at a rate of 1227 Px/Sec
String Benchmarked: Hello World
Average Px/Sec: 1016
Total Pixels processed: 8971
Total time taken: 7.781 seconds