VectorDrawing slowness

Just starting out? Need help? Post your questions and find answers here.
Lima
User
User
Posts: 43
Joined: Tue Jul 14, 2015 2:52 pm

VectorDrawing slowness

Post by Lima »

Why is the first run so slow?
Is there any way to solve this?
My thanks to anyone who can help.
(If you have already run some software that uses the same library, the delay is not that great.)

Code: Select all



Procedure TestVectorOutput()
  Static i=0
  i+1
  LoadFont(0,"",8,#PB_Font_Bold)
  
              CreateImage(0,100,100,24,$808080)
time=ElapsedMilliseconds()
  StartVectorDrawing(ImageVectorOutput(0))
 
     VectorFont(FontID(0),16)
;
       MovePathCursor(5,5)

        DrawVectorText("test "+Str(i))
        StopVectorDrawing()
   
        
        ImageGadget(0,200,120,0,0, ImageID(0))
        
        SetGadgetText(2,Str(ElapsedMilliseconds()-time))
        
      EndProcedure
      
      
   OpenWindow(0, 0, 0, 600, 720, "test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
       
   TextGadget(1,200,20,90,25,"Elapsed time :")
   StringGadget(2,300,20,100,25,"")
   ButtonGadget(3,200,600,140,25,"Run program")
   
   TestVectorOutput()
   
   Repeat
     
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 3 

                FreeGadget(0)
              
                  TestVectorOutput()
              
         EndSelect

       EndSelect
     Until Event = #PB_Event_CloseWindow  
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: VectorDrawing slowness

Post by mk-soft »

Still goes fast here, but
it is better not to create a new image and ImageGadget every time. That saves a lot of time.

Code: Select all

Procedure TestVectorOutput()
  Static i=0
  i+1
  LoadFont(0,"",8,#PB_Font_Bold)
  
  time=ElapsedMilliseconds()
  StartVectorDrawing(ImageVectorOutput(0))
  
  VectorSourceColor($FF808080)
  FillVectorOutput()
  
  VectorFont(FontID(0),16)
  VectorSourceColor($FF00FDFD)
  ;
  MovePathCursor(5,5)
  
  DrawVectorText("test "+Str(i))
  StopVectorDrawing()
  
  SetGadgetState(0, ImageID(0))
  
  SetGadgetText(2,Str(ElapsedMilliseconds()-time))
  
EndProcedure


OpenWindow(0, 0, 0, 600, 720, "test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)

ImageGadget(0,200,120,0,0, 0)
TextGadget(1,200,20,90,25,"Elapsed time :")
StringGadget(2,300,20,100,25,"")
ButtonGadget(3,200,600,140,25,"Run program")

CreateImage(0,100,100,24,$808080)

TestVectorOutput()

Repeat
  
  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 3 
          TestVectorOutput()
          
      EndSelect
      
  EndSelect
Until Event = #PB_Event_CloseWindow  
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: VectorDrawing slowness

Post by STARGÅTE »

Since I am using Windows 10, the first call of StartVectorDrawing() is also on my system very slow, probably due to some background initialization of the GDI+ lib. Some times it takes 1 second to see the drawing (e.g. in a canvas gadget). But just the first call during a windows session.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Lima
User
User
Posts: 43
Joined: Tue Jul 14, 2015 2:52 pm

Re: VectorDrawing slowness

Post by Lima »

The changes introduced by mk-soft have not changed the situation, the execution after the computer starts is still very long.
(Windows 7 and 10, PB 5.73)

Thank you all.
Post Reply