Page 1 of 1

DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 11:35 am
by Josh
Drawing on a image with the same size like the source, needs double time:

Code: Select all

CreateImage  (0, 500, 300, 32)

CreateImage  (1, 499, 299, 32)
CreateImage  (2, 499, 300, 32)
CreateImage  (3, 500, 299, 32)
CreateImage  (4, 500, 300, 32)
CreateImage  (5, 500, 301, 32)
CreateImage  (6, 501, 300, 32)
CreateImage  (7, 501, 301, 32)

StartDrawing (ImageOutput (0))
  Box (0, 0, 500, 300, #Red)
StopDrawing()

For j = 1 To 7
  time = ElapsedMilliseconds()
  StartDrawing (ImageOutput (j))
    For i = 1 To 10000
      DrawImage (ImageID (0), 0, 0)
    Next
  StopDrawing()
  time = ElapsedMilliseconds() - time
  Debug "" + ImageWidth(j) + " x " + ImageHeight(j) +  " = "  + time + " ms"
Next j
Testet: Win7, Pb5.11

Pb x32:
499 x 299 = 3697 ms
499 x 300 = 3713 ms
500 x 299 = 3729 ms
500 x 300 = 5553 ms
500 x 301 = 3744 ms
501 x 300 = 3744 ms
501 x 301 = 3698 ms

Pb x64:
499 x 299 = 2200 ms
499 x 300 = 2278 ms
500 x 299 = 2215 ms
500 x 300 = 4446 ms
500 x 301 = 2215 ms
501 x 300 = 2465 ms
501 x 301 = 2184 ms

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 1:00 pm
by jesperbrannmark
I tried 64 bit 5.11 and for me it was not double time... also tried 5.10 and could say see the same trend there but 5.11 seem faster in general?
Is it a bug really?

Pb 5.11 64 bit
499 x 299 = 2527 ms
499 x 300 = 2543 ms
500 x 299 = 2543 ms
500 x 300 = 2839 ms
500 x 301 = 2559 ms
501 x 300 = 2574 ms
501 x 301 = 2527 ms

pb 5.10 32 bit
499 x 299 = 4290 ms
499 x 300 = 4306 ms
500 x 299 = 4274 ms
500 x 300 = 4337 ms
500 x 301 = 4306 ms
501 x 300 = 4321 ms
501 x 301 = 4337 ms

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 1:16 pm
by Rings
please, never do some time measurements with debugger ON !!!

if you try this:

Code: Select all

;CreateImage  (0, 600, 400, 32)
CreateImage  (0, 500, 300, 32)

CreateImage  (1, 499, 299, 32)
CreateImage  (2, 499, 300, 32)
CreateImage  (3, 500, 299, 32)
CreateImage  (4, 500, 300, 32)
CreateImage  (5, 500, 301, 32)
CreateImage  (6, 501, 300, 32)
CreateImage  (7, 501, 301, 32)

StartDrawing (ImageOutput (0))
  Box (0, 0, 500, 300, #Red)
StopDrawing()

If #PB_Compiler_Debugger =1

   MessageRequester("Info","debugger is on",0)
   End
EndIf   


st.s
For j = 1 To 7
  time = ElapsedMilliseconds()
  StartDrawing (ImageOutput (j))
    For i = 1 To 10000
      DrawImage (ImageID (0), 0, 0)
    Next
  StopDrawing()
  st +  Str(j) + "=" +  Str(ElapsedMilliseconds() - time) + Chr(13) + Chr(10)
Next j

MessageRequester("Info",st,0)


you will see only small difference. I bet this has done with checking/drawing the borders. if you use a bigger image to draw on (see first commented line) then all measurements are nearly the same.
Not a bug, Topic moved ..

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 1:47 pm
by Josh
Rings wrote:please, never do some time measurements with debugger ON !!!
you will see only small difference.
The debugger discussion i had in the German forum. There are no (or only marginal) differences with or without debugger. See this following times with your code an compare it with the times of my first posting:

Pb x32
1=3698
2=3681
3=3651
4=5772
5=3697
6=3697
7=3682

Pb x64
1=2153
2=2246
3=2169
4=4415
5=2184
6=2433
7=2169
Rings wrote:if you use a bigger image to draw on (see first commented line) then all measurements are nearly the same.
Not a bug, Topic moved ..
Testing with your commented line is completely irrelevant, because this has nothing to do with the topic. In this case you don't draw in a image with the same size.

Please move back to the bug section, because I don't want to make a new topic in the bug forum!

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 2:06 pm
by luis
I cannot confirm this:

Win7 x64, Pb5.11

Pb x32:

Code: Select all

499 x 299 = 2870 ms
499 x 300 = 2839 ms
500 x 299 = 2824 ms
500 x 300 = 2761 ms
500 x 301 = 2855 ms
501 x 300 = 2917 ms
501 x 301 = 2871 ms
Pb x64:

Code: Select all

499 x 299 = 1888 ms
499 x 300 = 1965 ms
500 x 299 = 1919 ms
500 x 300 = 1903 ms
500 x 301 = 1904 ms
501 x 300 = 1934 ms
501 x 301 = 1950 ms
Even if it were slower (and it's not in my case, same for jesperbrannmark) it would be a request for an optimization (if possible). Not really a bug since it's working.
So I bet that asking to have this moved back in the bug section is only to see this moved again later to coding questions.

Maybe depends on something else beyond PB at this point.

Josh wrote: Please move back to the bug section, because I don't want to make a new topic in the bug forum!
That would be like saying to the moderator "up yours!" IMHO

Nothing wrong with that if that's what you want. :wink:

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 2:35 pm
by ts-soft
Josh wrote:The debugger discussion i had in the German forum. There are no (or only marginal) differences with or without debugger.
NicTheQuick wrote:Also hier unter Linux x64 kriege ich folgende Ergebnisse:
Debugger Window wrote:4039
5059
Ohne Debugger kommt das raus:
4100
3998
5059 - 4039 = 1020 difference with Debugger
4100 - 3998 = 102 difference without Debugger.

10 : 1 is marginal?

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 2:37 pm
by Josh
luis wrote:So I bet that asking to have this moved back in the bug section is only to see this moved again later to coding questions.
I opened only few topics in the bug section and it was always the same. Members in this forum said that is no bug, that can run, you have to do this or that and so on. Although my bug reports where nonsense in the eyes of some users here, Fred repaired or marked it as bug.

So it would be possible that moved back from the bug section again, but I think this decision should be made by Fred or Freak.
luis wrote:That would be like saying to the moderator "up yours!" IMHO
Not so crass. But when Rings don't check the problem (I described in the bottom of my last posting), I will open a new topic. Very easy.

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 3:19 pm
by Josh
In German forum I learned, that this effect is only with 32 bit images.

Re: DrawImage: Draw to image with same size need too long

Posted: Wed Apr 03, 2013 4:16 pm
by Rings
Josh wrote: Not so crass. But when Rings don't check the problem (I described in the bottom of my last posting), I will open a new topic. Very easy.
Very easy to do some other stuff here.

Maybe you can describe your PC ?
Perhaps it has something to do with a gfx card, antivirus etc ?

So long as it is not a reproducable problem
(and i mean on my different PC's and other users)
i can't move this topic back to bug-section.
And again, Using "DebuggerOn " is bad practice
for time measurement.

Re: DrawImage: Draw to image with same size need too long

Posted: Thu Apr 04, 2013 8:03 pm
by Josh
Rings wrote:Maybe you can describe your PC ?
Perhaps it has something to do with a gfx card, antivirus etc ?
For your analysis:
Processor: AMD FX-4100 Quad-CoreProcessor 3,6 GHz
Ram: 8 GB
Grafikcard: AMD 760G
Antivirus: Avira Free
OS: Window 7 Ultimate x64
Rings wrote:So long as it is not a reproducable problem
(and i mean on my different PC's and other users)i can't move this topic back to bug-section.
It is reproduceable, you had confirmed it. Maybe the differences are not so large as in my case, but it's obvious that there is running something wrong. Tendency confirmed by:

Re: DrawImage: Draw to image with same size need too long

Posted: Thu Apr 04, 2013 10:14 pm
by idle
Wow is the most likely explanation, it's called thunking aka windows on windows!

Re: DrawImage: Draw to image with same size need too long

Posted: Fri Apr 05, 2013 12:04 am
by Josh
idle wrote:Wow is the most likely explanation, it's called thunking aka windows on windows!
Test on Win XP Professional 32bit (plane installation, no VM) show nearly the same result:

1=3641
2=3672
3=3640
4=5282
5=3672
6=3687
7=3656

Re: DrawImage: Draw to image with same size need too long

Posted: Fri Apr 05, 2013 12:43 am
by buddymatkona
My Win7 x64 runs this 1.5 times faster than x86 with or without Debug. Maybe idle is right or some optimization in the PB x64 version is missing from the x86 version.
Unless you are sure Fred already understands the difference, it is good to point out these things.

Re: DrawImage: Draw to image with same size need too long

Posted: Fri Apr 05, 2013 1:16 am
by Josh
buddymatkona wrote:My Win7 x64 runs this 1.5 times faster than x86 with or without Debug. Maybe idle is right or some optimization in the PB x64 version is missing from the x86 version.
Unless you are sure Fred already understands the difference, it is good to point out these things.
The topic here is not the difference between X64 and x86. The problem I posted is only, that drawing a image to another image with the same size needs longer than drawing to a image with different size.

Re: DrawImage: Draw to image with same size need too long

Posted: Fri Apr 05, 2013 4:40 am
by buddymatkona
@Josh
Sorry. I did not mean to ignore your point. :(
Here are my results for PB 5.11 Win7

x64
  • 499 x 299 = 1919 ms
    499 x 300 = 1919 ms
    500 x 299 = 1903 ms
    500 x 300 = 1934 ms
    500 x 301 = 1919 ms
    501 x 300 = 1934 ms
    501 x 301 = 1919 ms
x86
  • 499 x 299 = 2808 ms
    499 x 300 = 2793 ms
    500 x 299 = 2714 ms
    500 x 300 = 2528 ms ; a bit faster
    500 x 301 = 2808 ms
    501 x 300 = 2808 ms
    501 x 301 = 2776 ms