Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hardware vs Software
#1
I had a couple of people on Discord message me asking about if I could toss up a performance difference between software and hardware images for them.  I swear, I know I had some already here somewhere, but I couldn't find them when I snooped for them earlier, so -- by request -- here's a quick and dirty demo of the difference:

Code: (Select All)
Screen _NewImage(1280, 720, 32)

box = _NewImage(320, 180, 32) 'make a screen to just hold a box
Cls , &HFFFF0000&&, box 'make that box red

count = 0: t# = Timer + 1
Do
count = count + 1
Cls
If Timer > t# Then
box_moves = count
count = 0
t# = Timer + 1
End If
bx = (bx + 1) Mod 960
_PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
_PutImage (bx, 100), box
_Display
Loop Until _KeyHit


_Delay .5
_KeyClear

box2 = _CopyImage(box, 33) 'make us a hardware image of that same box
_DisplayOrder _Hardware , _Hardware1 'and we're only going to display hardware screens
t# = Timer + 1: count = 0
Do
count = count + 1
If Timer > t# Then
hardbox_moves = count
count = 0
t# = Timer + 1
Cls
_PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
_PrintString (0, 20), "The box moved" + Str$(hardbox_moves) + " times per second with hardware images."
If temp <> 0 Then _FreeImage temp
temp = _CopyImage(0, 33)
End If
bx = (bx + 1) Mod 960
_PutImage , temp 'place this image on the hardware screen
_PutImage (bx, 100), box2, 1 'place this image on the hardware screen 1 (the 2nd hardware screen)
_Display
Loop Until _KeyHit
System


Run that. Open your program manager and watch your CPU usage. Let it go for several seconds and you can see how quickly it moves a simple red box across the screen for you.

Then hit the space bar... Give it a couple of seconds to swap over from software to hardware images, and watch and see what the difference in those numbers might be.

Note that in the second portion of the program, where we're tossing out our hardware image, that I'm STILL drawing to a software image in the background. (Well, clearing it and printing to it.) Then I'm making a hardware copy of that image to display. While ALSO using a second hardware image for the box itself...

And yet, it still runs just a *wee* bit faster for us, with lesser CPU usage and all the other benefits that hardware brings over software.

Now tell me, is it perhaps a *wee* bit faster on your machines as well?
Reply
#2
(10-11-2024, 11:45 PM)SMcNeill Wrote: I had a couple of people on Discord message me asking about if I could toss up a performance difference between software and hardware images for them.  I swear, I know I had some already here somewhere, but I couldn't find them when I snooped for them earlier, so -- by request -- here's a quick and dirty demo of the difference:

Code: (Select All)
Screen _NewImage(1280, 720, 32)

box = _NewImage(320, 180, 32) 'make a screen to just hold a box
Cls , &HFFFF0000&&, box 'make that box red

count = 0: t# = Timer + 1
Do
    count = count + 1
    Cls
    If Timer > t# Then
        box_moves = count
        count = 0
        t# = Timer + 1
    End If
    bx = (bx + 1) Mod 960
    _PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
    _PutImage (bx, 100), box
    _Display
Loop Until _KeyHit


_Delay .5
_KeyClear

box2 = _CopyImage(box, 33) 'make us a hardware image of that same box
_DisplayOrder _Hardware , _Hardware1 'and we're only going to display hardware screens
t# = Timer + 1: count = 0
Do
    count = count + 1
    If Timer > t# Then
        hardbox_moves = count
        count = 0
        t# = Timer + 1
        Cls
        _PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
        _PrintString (0, 20), "The box moved" + Str$(hardbox_moves) + " times per second with hardware images."
        If temp <> 0 Then _FreeImage temp
        temp = _CopyImage(0, 33)
    End If
    bx = (bx + 1) Mod 960
    _PutImage , temp 'place this image on the hardware screen
    _PutImage (bx, 100), box2, 1 'place this image on the hardware screen 1 (the 2nd hardware screen)
    _Display
Loop Until _KeyHit
System


Run that.  Open your program manager and watch your CPU usage.  Let it go for several seconds and you can see how quickly it moves a simple red box across the screen for you.

Then hit the space bar...  Give it a couple of seconds to swap over from software to hardware images, and watch and see what the difference in those numbers might be.

Note that in the second portion of the program, where we're tossing out our hardware image, that I'm STILL drawing to a software image in the background.  (Well, clearing it and printing to it.)  Then I'm making a hardware copy of that image to display.  While ALSO using a second hardware image for the box itself...

And yet, it still runs just a *wee* bit faster for us, with lesser CPU usage and all the other benefits that hardware brings over software.

Now tell me, is it perhaps a *wee* bit faster on your machines as well?
WOW.

Hi.
Reply
#3
(10-12-2024, 03:11 AM)gaslouk Wrote:
(10-11-2024, 11:45 PM)SMcNeill Wrote: I had a couple of people on Discord message me asking about if I could toss up a performance difference between software and hardware images for them.  I swear, I know I had some already here somewhere, but I couldn't find them when I snooped for them earlier, so -- by request -- here's a quick and dirty demo of the difference:

Code: (Select All)
Screen _NewImage(1280, 720, 32)

box = _NewImage(320, 180, 32) 'make a screen to just hold a box
Cls , &HFFFF0000&&, box 'make that box red

count = 0: t# = Timer + 1
Do
    count = count + 1
    Cls
    If Timer > t# Then
        box_moves = count
        count = 0
        t# = Timer + 1
    End If
    bx = (bx + 1) Mod 960
    _PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
    _PutImage (bx, 100), box
    _Display
Loop Until _KeyHit


_Delay .5
_KeyClear

box2 = _CopyImage(box, 33) 'make us a hardware image of that same box
_DisplayOrder _Hardware , _Hardware1 'and we're only going to display hardware screens
t# = Timer + 1: count = 0
Do
    count = count + 1
    If Timer > t# Then
        hardbox_moves = count
        count = 0
        t# = Timer + 1
        Cls
        _PrintString (0, 0), "The box moved" + Str$(box_moves) + " times per second with software images."
        _PrintString (0, 20), "The box moved" + Str$(hardbox_moves) + " times per second with hardware images."
        If temp <> 0 Then _FreeImage temp
        temp = _CopyImage(0, 33)
    End If
    bx = (bx + 1) Mod 960
    _PutImage , temp 'place this image on the hardware screen
    _PutImage (bx, 100), box2, 1 'place this image on the hardware screen 1 (the 2nd hardware screen)
    _Display
Loop Until _KeyHit
System


Run that.  Open your program manager and watch your CPU usage.  Let it go for several seconds and you can see how quickly it moves a simple red box across the screen for you.

Then hit the space bar...  Give it a couple of seconds to swap over from software to hardware images, and watch and see what the difference in those numbers might be.

Note that in the second portion of the program, where we're tossing out our hardware image, that I'm STILL drawing to a software image in the background.  (Well, clearing it and printing to it.)  Then I'm making a hardware copy of that image to display.  While ALSO using a second hardware image for the box itself...

And yet, it still runs just a *wee* bit faster for us, with lesser CPU usage and all the other benefits that hardware brings over software.

Now tell me, is it perhaps a *wee* bit faster on your machines as well?
WOW.

Hi.
You quoted that entire post just to post, "WOW.".... Wow!.... Oops. Big Grin

Pete
Reply
#4
Okay, 104 times per second vs 400,000 times per second. Honestly, I barely noticed. Undecided

Pete Big Grin
Shoot first and shoot people who ask questions, later.
Reply




Users browsing this thread: 3 Guest(s)