; *=-----------------------------------------------------------------=* ; This Example compares the speed of filling the entire screen ; with dots using the DotC against the FastDot command. ; ; On my test machine FastDot is about twice as fast as Dotc ; *=-----------------------------------------------------------------=* ; ; Open a Screen (windowed) that is 500x * 400y pixels in size OpenScreen 500,400,32,1 ; Set the Maxtest Variable to 50. This will be the number times ; the following tests will be performed MaxTests=100 ; ------------------------------------------------- ; ------------------------------------------------- ; TEST 1 - Fill the Screen using DOTC command ; ------------------------------------------------- ; ------------------------------------------------- ; start of a Repeat/Until Loop Repeat Cls 0 ; Add 1 to the frames counter (used the calc the average fill time bellow) Inc Frames ; Move the current base colour into the current colour variable CurrentColour=BaseColour ; Add 1 to the base colour value BaseColour=BaseColour+RGB(1,2,3) ; get the timer() value at the, Start_of_Dot_Fill_Time=Timer() ; Fill the Screen Using DotC. ; Lock the buffer prior to the doing any pixel fill usiong DotC. LockBuffer ; Ylp will loop down the screen Y axis For Ylp=0 To GetScreenHeight()-1 ; Xlp will loop across the screen X axis For Xlp=0 To GetScreenWidth()-1 ; Draw a dot/pixel at this position DotC Xlp,ylp,CurrentColour Next ; At the end of each row, chaneg the current row colour CurrentColour=CurrentColour + RGB(3,2,1) Next ; Once your done drawing, unlock the buffer again. UnLockBuffer ; Calc the time in millisecond filling the screen took Time_Dot_takes=Timer()-Start_of_Dot_Fill_Time ; Calc the Total Time TotalTime#=TotalTime#+Time_DOT_Takes ; Calc the average Test1_Average#=TotalTime#/frames ; Display the average Print "TEST #1 - Filling Screen With DOTC command" Print "Average Fill Time:"+Str$(Test1_Average#) Print "Frame:"+Str$(frames) ; Show the Screen to the user Sync ; Repeat/ Until the Space Key is pressed Until Frames=MaxTests ; ------------------------------------------------- ; ------------------------------------------------- ; TEST 2 - Fill the Screen using FastDOT command ; ------------------------------------------------- ; ------------------------------------------------- Frames=0 TotalTime#=0 ; start of a Repeat/Until Loop Repeat Cls 0 ; Add 1 to the frames counter (used the calc the average fill time bellow) Inc Frames ; Move the current base colour into the current colour variable CurrentColour=BaseColour ; Subtract the same colour fromt eh base colour (so the colours move backward) BaseColour=BaseColour-RGB(1,2,3) ; get the timer() value at the, Start_of_Dot_Fill_Time=Timer() ; Fill the Screen Using DotC. ; Lock the buffer prior to the doing any pixel fill usiong DotC. LockBuffer ; Ylp will loop down the screen Y axis For Ylp=0 To GetScreenHeight()-1 ; Xlp will loop across the screen X axis For Xlp=0 To GetScreenWidth()-1 ; Draw a dot/pixel at this position FastDot Xlp,ylp,CurrentColour Next ; At the end of each row, chaneg the current row colour CurrentColour=CurrentColour + RGB(3,2,1) Next ; Once your done drawing, unlock the buffer again. UnLockBuffer ; Calc the time in millisecond filling the screen took Time_Dot_takes=Timer()-Start_of_Dot_Fill_Time ; Calc the Total Time TotalTime#=TotalTime#+Time_DOT_Takes ; Calc the average Test2_Average#=TotalTime#/frames ; Display the average Print "TEST #2 - Filling Screen With FastDOT command" Print "Average Fill Time:"+Str$(Test2_Average#) Print "Frame:"+Str$(frames) ; Show the Screen to the user Sync ; Repeat/ Until the Space Key is pressed Until Frames=MaxTests Cls 0 Print "Results" Print "Test1 (dotc) average fill time:"+Str$(Test1_average#) Print "Test2 (Fastdot) average fill time:"+Str$(Test2_average#) s$=Str$(Test1_average#/Test2_average#) Print "Fastdot is "+s$+" Faster than DotC" Sync WaitKey End |