It is currently Wed Jul 18, 2018 6:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: (Fixed) Massive speed differences between PB versions
PostPosted: Sun Jan 29, 2017 10:07 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 727
Location: Denmark
EDIT: Speed issue has been fixed by the team in PB 5.70 Beta 1



Edit: 05/mar/2017

Added stress test 3 at the end of this post

NOTE: The team is aware of the problems.

Code:
; Object creation And rendering stress TEST
; -------------------------------------
; Decrease/Increase the #XNUM And #YNUM
; ----------------------------------------------------
; Tested with PureBasic 5.43 and 5.60 Betas
; It's improved in beta 4 and 5 but still pretty slow
; when compaired to the older version.
;-----------------------------------------------------
DisableDebugger

InitEngine3D()
InitSprite()
InitKeyboard()

#XNUM = 25 
#YNUM = 25

Structure _base
  id.i
  ms.i
  ma.i
  tx.i
EndStructure

Structure _TimDif
  ms.i
  Primitive.s
  avgFrame.i
  numOfMesh.i
  PhysOn.i
EndStructure

Global Dim m._base(#XNUM, #YNUM)  ; (625 objects)

Declare.i CreateTheObjects(Index.i = 1)

Global tx.s, Quit.i, RET.i, Index.i = 0
Global Dim da._TimDif(3)

OpenWindow(0, 0, 0, 1024, 768, "Stress test (Press 1,2,3 for testing different objects)", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
EditorGadget(1, 801, 0, 222, 20)
EditorGadget(2, 801, 30, 222, 20)
EditorGadget(3, 801, 60, 222, 20)
EditorGadget(4, 801, 90, 222, 20)
EditorGadget(5, 801, 120, 222, 20)

OpenWindowedScreen(WindowID(0), 0, 0, 800, 768)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 65)

Index = 1
da(Index)\Primitive = "CreateCube"
da(Index)\PhysOn = #False
da(index)\numOfMesh = #XNUM*#YNUM
RET = CreateTheObjects(1)

CreatePlane(0, 10, 10, 10, 10, 1, 1)
CompilerIf #PB_Compiler_Version >= 550
  CreateTexture(0, 10, 10, "PlaneTexture")
CompilerElse
  CreateTexture(0, 10, 10)
CompilerEndIf
StartDrawing(TextureOutput(0))
Box(0, 0, 10, 10, $777777)
StopDrawing()
CreateMaterial(0, TextureID(0))
CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 0)
RotateEntity(0, 0, 40, 0)
MoveEntity(0, 0, -25, 0)
ScaleEntity(0, 20, 1, 20)
CreateEntityBody(0, #PB_Entity_StaticBody)

Repeat
  Repeat
    ev = WindowEvent()
    If ev = #PB_Event_CloseWindow : Quit = #True : EndIf
  Until  ev = 0
 
  For y = 0 To #YNUM
    For x = 0 To #XNUM
      RotateEntity(m(x,y)\id, 0.5, -1, 0.8, #PB_Relative)
    Next x
  Next y
 
  RenderWorld()
 
  FlipBuffers()
 
  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_1)
    Index = 1
    da(Index)\PhysOn = #False
    RET = CreateTheObjects(1)
    da(index)\numOfMesh = #XNUM*#YNUM
    da(Index)\Primitive = "CreateCube"
  ElseIf KeyboardReleased(#PB_Key_2)
    Index = 2
    da(Index)\PhysOn = #False
    RET = CreateTheObjects(2)
    da(index)\numOfMesh = #XNUM*#YNUM
    da(Index)\Primitive = "CreateCylinder"
  ElseIf  KeyboardReleased(#PB_Key_3)
    index = 3
    da(Index)\PhysOn = #False
    RET = CreateTheObjects(3)
    da(index)\Primitive = "CreateSphere"
    da(index)\numOfMesh = #XNUM*#YNUM
  EndIf
  If KeyboardReleased(#PB_Key_Space)
    EnableWorldPhysics(1)
    da(Index)\PhysOn = #True
  EndIf
  SetGadgetText(1, "Type created: " + da(Index)\Primitive)
  SetGadgetText(2, "Creation time: " + Str(da(Index)\ms))
  SetGadgetText(3, "Average Fps: " + Str(da(Index)\avgFrame))
  SetGadgetText(4, "Num of objects: " + Str(da(Index)\numOfMesh))
  SetGadgetText(5, "Physics Active: " + Str(da(Index)\PhysOn))
 
  da(index)\avgFrame = Engine3DStatus(#PB_Engine3D_AverageFPS)
Until KeyboardPushed(#PB_Key_Escape) Or Quit = #True


Procedure.i CreateTheObjects(Index.i = 1)
  Protected elap.i
  Protected x.i, y.i, ms.i, txt.s
  EnableWorldPhysics(0)
  ;free everything And start over....
  For y = 0 To #YNUM
    For x = 0 To #XNUM
      With m(x,y)
        If IsEntity(\id) > 0
          FreeEntityBody(\id)
          FreeEntity(\id)
          FreeMaterial(\ma)
          FreeTexture(\tx)
          FreeMesh(\ms)
        EndIf
      EndWith
    Next x
  Next y
  ;Populate everything once again...Time it...
  elap = ElapsedMilliseconds()
  For y = 0 To #YNUM
    For x = 0 To #XNUM
      With m(x,y)
        Select Index
          Case 1 ; cube
            \ms = CreateCube(#PB_Any, 0.5)
            txt = "Cube"
          Case 2 ; cylinder
            \ms = CreateCylinder(#PB_Any, 0.5, 0.5)
            txt = "Cylinder"
          Case 3 ; Sphere
            \ms = CreateSphere(#PB_Any, 0.5)
            txt = "Sphere"
        EndSelect
        CompilerIf #PB_Compiler_Version >= 550
          \tx = CreateTexture(#PB_Any, 10, 10, "Texture_" + Str(Random(80000, 1000)))
        CompilerElse
          \tx = CreateTexture(#PB_Any, 10, 10)
        CompilerEndIf
        StartDrawing(TextureOutput(\tx))
        Box(0, 0, 10, 10, RGB(Random(255,100), Random(255,100), Random(255,100)))
        StopDrawing()
        \ma = CreateMaterial(#PB_Any, TextureID(\tx))
        \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -(#XNUM/2) + (x+1), -(#YNUM/2) + (y+1), 0)
        Select Index
          Case 1
            CreateEntityBody(\id, #PB_Entity_BoxBody)  ;edit..Tried with boxbody on each - now changed to the appropriate bodies.
          Case 2
            CreateEntityBody(\id, #PB_Entity_CylinderBody)
          Case 3
            CreateEntityBody(\id, #PB_Entity_SphereBody)
        EndSelect
      EndWith
    Next x
  Next y
  da(Index)\ms = ElapsedMilliseconds()-elap
  ProcedureReturn #True
EndProcedure


Stress test 2.
Escape to exit.

Code:
;Stress test 2 (random objects)
;Results on my system - See signature
;Purebasic 5.43/5.44 LTS
;Approx. 730 objects created before fps begins to drop.
;-----------------------------------------------------------------
;PureBasic 5.60 (all betas)
;Approx. 270-290 objects created before fps begins to drop - drastically
;-----------------------------------------------------------------

InitEngine3D()
InitSprite()
InitKeyboard()

Structure _object
  id.i
  ma.i
  ms.i
  tx.i
EndStructure

Structure _Box
  left._object
  right._object
  front._object
  back._object
  bottom._object
EndStructure

Declare.i MakeNewObject()
Declare.i MakeBox()

Global NewList ob._object(), b._Box
Global elap.i

AntialiasingMode(#PB_AntialiasingMode_x6)
OpenWindow(0, 0, 0, 1024, 768, "Stress test 2", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 768)
StringGadget(0, 801, 0, 224, 25, "")
StringGadget(1, 801, 26, 224, 25, "")
StringGadget(2, 801, 52, 224, 25, "")
StringGadget(3, 801, 79, 224, 25, "")
StringGadget(4, 801, 110, 224, 25, "")
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 25)

MakeBox()
SetGadgetText(4, "Version: " + #PB_Compiler_Version)

Repeat
 
  Repeat
    ev = WindowEvent()
  Until ev = 0
  If ElapsedMilliseconds() - elap > 100
    MakeNewObject()
    elap = ElapsedMilliseconds()
  EndIf
  RenderWorld()
 
  FlipBuffers()
  SetGadgetText(0, Str(ListSize(ob())-1) + " objects")
  SetGadgetText(1, Str(Engine3DStatus(#PB_Engine3D_AverageFPS))+ " fps")
  SetGadgetText(2, Str(Engine3DStatus(#PB_Engine3D_NbRenderedTriangles)) + " triangles")
  SetGadgetText(3, Str(Engine3DStatus(#PB_Engine3D_NbRenderedBatches)) + " batches")
  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape)

Procedure.i MakeBox()
  Protected tx.i, ma.i
  CompilerIf #PB_Compiler_Version >= 550
    tx = CreateTexture(#PB_Any, 100, 100, "Glassy")
  CompilerElse
    tx = CreateTexture(#PB_Any, 100, 100)
  CompilerEndIf
  StartDrawing(TextureOutput(tx))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  Box(0, 0, 100, 100, $11FDC045)
  StopDrawing()
  ma = CreateMaterial(#PB_Any, TextureID(tx))
  MaterialBlendingMode(ma, #PB_Material_Color)
 
  With b\front
    \ms = CreatePlane(#PB_Any, 12, 14, 1, 1, 1, 1)
    \id = CreateEntity(#PB_Any,MeshID(\ms), MaterialID(ma), 0, 0, -5)
    RotateEntity(\id, 90, 0, 0)
  EndWith
  With b\back
    \ms = CreatePlane(#PB_Any, 12, 14, 1, 1, 1, 1)
    \id = CreateEntity(#PB_Any,MeshID(\ms), MaterialID(ma), 0, 0, 5)
    RotateEntity(\id, 90, 0, 0)
  EndWith
  With b\left
    \ms = CreatePlane(#PB_Any, 14, 12, 1, 1, 1, 1)
    \id = CreateEntity(#PB_Any,MeshID(\ms), MaterialID(ma), -5, 0, 0)
    RotateEntity(\id, 0, 0, -90)
  EndWith
  With b\right
    \ms = CreatePlane(#PB_Any, 14, 12, 1, 1, 1, 1)
    \id = CreateEntity(#PB_Any,MeshID(\ms), MaterialID(ma), 5, 0, 0)
    RotateEntity(\id, 0, 0, 90)
  EndWith
  With b\bottom
    \ms = CreateCube(#PB_Any, 1)
    \id = CreateEntity(#PB_Any,MeshID(\ms), MaterialID(ma), 0, -5, 0)
    ScaleEntity(\id, 10, 1, 10) 
  EndWith
  CreateEntityBody(b\back\id, #PB_Entity_StaticBody)
  CreateEntityBody(b\front\id, #PB_Entity_StaticBody)
  CreateEntityBody(b\bottom\id, #PB_Entity_StaticBody)
  CreateEntityBody(b\left\id, #PB_Entity_StaticBody)
  CreateEntityBody(b\right\id, #PB_Entity_StaticBody)
EndProcedure

Procedure.i MakeNewObject()
  Protected Index.i = Random(100)
  AddElement(ob())
  CompilerIf #PB_Compiler_Version >= 550
    ob()\tx = CreateTexture(#PB_Any, 10, 10, "Texture_" + Str(Random(20000,100)))
  CompilerElse
    ob()\tx = CreateTexture(#PB_Any, 10, 10)
  CompilerEndIf
  StartDrawing(TextureOutput(ob()\tx))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  Box(0, 0, 10, 10, RGBA(Random(255,30), Random(255,30), Random(255, 30), Random(255,20)))
  StopDrawing()
  ob()\ma = CreateMaterial(#PB_Any, TextureID(ob()\tx))
  MaterialBlendingMode(ob()\ma, #PB_Material_Add)
 
  CompilerIf #PB_Compiler_Version <= 545
      Select Index
        Case 0 To 25
          ob()\ms = CreateCube(#PB_Any, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_BoxBody)
        Case 26 To 50
          ob()\ms = CreateCylinder(#PB_Any, 0.5, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_CylinderBody)
        Case 51 To 75
          ob()\ms = CreateCone(#PB_Any, 0.5, 0.5, 16, 16)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_CapsuleBody)
        Default
          ob()\ms = CreateSphere(#PB_Any, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_SphereBody)
    EndSelect         
  CompilerElse
      Select Index
        Case 0 To 25
          ob()\ms = CreateCube(#PB_Any, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_BoxBody)
        Case 26 To 50
          ob()\ms = CreateCylinder(#PB_Any, 0.5, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_CylinderBody)
        Case 51 To 75
          ob()\ms = CreateCone(#PB_Any, 0.5, 0.5, 16, 16)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_ConeBody)
         Default
          ob()\ms = CreateSphere(#PB_Any, 0.5)
          ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), 0, Random(10,8), 0)
          CreateEntityBody(ob()\id, #PB_Entity_SphereBody)
    EndSelect         
  CompilerEndIf
 EndProcedure


Stress test 3.

Code:
;Stress test 3 (Needs permission to write to file)
;PB 5.43/5.44 Versus PB 5.50 and up to 5.60 FINAL
;--------------------------------------------------------------------------------------
;KEYS
;SPACE KEY  - START/STOP THE CREATION OF PHYSICS OBJECTS
;RETURN KEY - RESETS THE STRESS TEST AND BEGINS ANEW (IT DOES NOT RESET PHYSICS CREATION PROCESS IF TURNED ON)
;NOTE:
;Decrease the number of objects in d\max (INIT() - procedure), when you add physics objects.
;1500 as maximum is way too many - unless you got a real beast of a machine.
;
;ESCAPE KEY EXITS PROGRAM
;
;If the framerate gets too low, a message appears, the log file is displayed and the program ends.
;--------------------------------------------------------------------------------------

DisableDebugger

InitEngine3D()
InitSprite()
InitKeyboard()

Structure _object
  id.i
  ma.i
  ms.i
  tx.i
EndStructure
Global NewList ob._object(), ground._object

Structure _Data
  count.i
  Max.i
  start.i
  interval.i
  txt.s
  phy.i
  phynum.i
  cam.i
  nod.i
EndStructure
Global d._Data

Declare.i Init()
Declare.i MakeNewObject()
Declare.f NewPos()
Declare.i ResetObjects()
Declare.i WriteTheTest()

Global quit.i, elap.i, node.i, ret.i, isSet.i = #False

AntialiasingMode(#PB_AntialiasingMode_x6)
OpenWindow(0, 0, 0, 1024, 768, "Stress test 3", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 768)
StringGadget(0, 801, 0, 224, 25, "")
StringGadget(1, 801, 26, 224, 25, "")
StringGadget(2, 801, 52, 224, 25, "")
StringGadget(3, 801, 79, 224, 25, "")
StringGadget(4, 801, 110, 224, 25, "")
StringGadget(5, 801, 140, 224, 25, "")
StringGadget(6, 801, 170, 224, 25, "")
TextGadget(7, 801, 200, 224, 25, "Physic object creation: " + Str(phy))

Init()

Repeat
 
  Repeat
    ev = WindowEvent()
    If ev = #PB_Event_CloseWindow : quit = #True : EndIf
  Until ev = 0
 
  If ListSize(ob()) < d\start
    ret = MakeNewObject()
  Else
    If d\start < d\Max
      d\start + d\interval
      ResetObjects()
    ElseIf d\start > d\Max-1 And isSet = #False
      d\txt + GetGadgetText(0) + #CRLF$
      d\txt + GetGadgetText(1) + #CRLF$
      d\txt + GetGadgetText(2) + #CRLF$
      d\txt + GetGadgetText(3) + #CRLF$
      d\txt + GetGadgetText(5) + #CRLF$
      d\txt + GetGadgetText(6) + #CRLF$ + #CRLF$
      WriteTheTest()
      isSet = #True
    EndIf
  EndIf
 
  RotateNode(d\nod, 0, 0.6, 0, #PB_Relative)
 
  RenderWorld()
 
  FlipBuffers()
  If isSet = #False
    SetGadgetText(0, Str(ListSize(ob())-1) + " objects")
    SetGadgetText(1, Str(Engine3DStatus(#PB_Engine3D_CurrentFPS))+ " fps")
    SetGadgetText(2, Str(Engine3DStatus(#PB_Engine3D_NbRenderedTriangles)) + " triangles")
    SetGadgetText(3, Str(Engine3DStatus(#PB_Engine3D_NbRenderedBatches)) + " batches")
    CompilerIf #PB_Compiler_Version >= 550
      SetGadgetText(5, "Time spent: " + Str(ElapsedMilliseconds()-elap) + " ms.")
    CompilerElse
      SetGadgetText(5, "Time spent: " + Str(ElapsedMilliseconds()-elap) + " ms.")
    CompilerEndIf
    SetGadgetText(6, "Physics objects: " + Str(d\phynum))
  EndIf
 
  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Space)
    If d\phy = #True : d\phy = #False : Else : d\phy = #True : EndIf
    SetGadgetText(7, "Physic object creation: " + Str(d\phy))
  EndIf
 
  If KeyboardReleased(#PB_Key_Return) ; Reset test
    d\start = d\interval
    d\txt = ""
    ret = ResetObjects()
    isSet = #False
  EndIf
  If ListSize(ob()) > 200 And Engine3DStatus(#PB_Engine3D_CurrentFPS) < 10
    MessageRequester("Fps too slow!!", "The fps is way to low! Decrease the d\max value accordingly (Init() procedure)" + #CRLF$ + "and run test again")
    d\txt + GetGadgetText(0) + #CRLF$
    d\txt + GetGadgetText(1) + #CRLF$
    d\txt + GetGadgetText(2) + #CRLF$
    d\txt + GetGadgetText(3) + #CRLF$
    d\txt + GetGadgetText(5) + #CRLF$
    d\txt + GetGadgetText(6) + #CRLF$ + #CRLF$
    WriteTheTest()
    isSet = #True
    End
  EndIf
Until KeyboardPushed(#PB_Key_Escape) Or quit = #True

Procedure.i MakeNewObject()
  Protected Index.i = Random(100)
  AddElement(ob())
  CompilerIf #PB_Compiler_Version >= 550
    ob()\tx = CreateTexture(#PB_Any, 10, 10, "Texture_" + Str(Random(20000,100)))
  CompilerElse
    ob()\tx = CreateTexture(#PB_Any, 10, 10)
  CompilerEndIf
  StartDrawing(TextureOutput(ob()\tx))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  Box(0, 0, 10, 10, RGBA(Random(255,30), Random(255,30), Random(255, 30), Random(255,20)))
  StopDrawing()
  ob()\ma = CreateMaterial(#PB_Any, TextureID(ob()\tx))
  MaterialBlendingMode(ob()\ma, #PB_Material_Add)
 
  CompilerIf #PB_Compiler_Version <= 545
    Select Index
      Case 0 To 25
        ob()\ms = CreateCube(#PB_Any, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_BoxBody) : d\phynum + 1 : EndIf
      Case 26 To 50
        ob()\ms = CreateCylinder(#PB_Any, 1, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_CylinderBody) : d\phynum + 1 :  EndIf
      Case 51 To 75
        ob()\ms = CreateCone(#PB_Any, 1, 1, 16, 16)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_ConeBody) : d\phynum + 1 :  EndIf
      Default
        ob()\ms = CreateSphere(#PB_Any, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_SphereBody) : d\phynum + 1 :  EndIf
    EndSelect         
  CompilerElse
    Select Index
      Case 0 To 25
        ob()\ms = CreateCube(#PB_Any, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_BoxBody) : d\phynum + 1 :  EndIf
      Case 26 To 50
        ob()\ms = CreateCylinder(#PB_Any, 1, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_CylinderBody) : d\phynum + 1 :  EndIf
      Case 51 To 75
        ob()\ms = CreateCone(#PB_Any, 1, 1, 16, 16)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_ConeBody) : d\phynum + 1 :  EndIf
      Default
        ob()\ms = CreateSphere(#PB_Any, 1)
        ob()\id = CreateEntity(#PB_Any, MeshID(ob()\ms), MaterialID(ob()\ma), NewPos(), NewPos(), NewPos())
        If d\phy = #True : CreateEntityBody(ob()\id, #PB_Entity_SphereBody) : d\phynum + 1 :  EndIf
    EndSelect         
  CompilerEndIf
  ProcedureReturn #True
EndProcedure

Procedure.i Init()
  d\cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
  MoveCamera(d\cam, 0, 0, 150)
  CameraLookAt(d\cam, 0, -30, 0)
  d\nod = CreateNode(#PB_Any, 0, 0, 0)
  AttachNodeObject(d\nod, CameraID(d\cam))
  ;Create ground
  With ground
    \ms = CreateCube(#PB_Any, 1)
    TransformMesh(\ms, 0, 0, 0, 180, 5, 180, 0, 0, 0)
    UpdateMeshBoundingBox(\ms)
    CompilerIf #PB_Compiler_Version >= 550
      \tx = CreateTexture(#PB_Any, 10, 10, "Groundtexture")
    CompilerElse
      \tx = CreateTexture(#PB_Any, 10, 10)
    CompilerEndIf
    StartDrawing(TextureOutput(\tx))
    DrawingMode(#PB_2DDrawing_Gradient)
    FrontColor($AAAAAA) : BackColor($D600A3)
    LinearGradient(0, 0, 10, 10)
    Box(0,0,10,10)
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx))
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, -60, 0)
    CreateEntityBody(\id, #PB_Entity_StaticBody)
  EndWith
  SetGadgetText(4, "Version: " + #PB_Compiler_Version)
  elap = ElapsedMilliseconds()
  d\Max = 1500   ; UNLESS YOU'RE RUNNING FAST PC, YOU MAY MAY TO LOWER THIS NUMBER!! RAISE IT IF YOU GOT A MUSCLE PC.
  d\interval = d\Max / 4
  d\start = d\interval
EndProcedure

Procedure.f NewPos()
  Protected max.f = 20, min.f = -20
  Protected Seed = Date()
  ProcedureReturn (Min + (Max - Min) * Random(Seed) / Seed)
EndProcedure

Procedure.i ResetObjects()
  ForEach ob()
    If IsEntity(ob()\id)
      FreeEntity(ob()\id)
      FreeMaterial(ob()\ma)
      FreeTexture(ob()\tx)
      FreeMesh(ob()\ms)
    EndIf
  Next
  ClearList(ob())
  d\txt + GetGadgetText(0) + #CRLF$
  d\txt + GetGadgetText(1) + #CRLF$
  d\txt + GetGadgetText(2) + #CRLF$
  d\txt + GetGadgetText(3) + #CRLF$
  d\txt + GetGadgetText(4) + #CRLF$
  d\txt + GetGadgetText(5) + #CRLF$
  d\txt + GetGadgetText(6) + #CRLF$ + #CRLF$
  d\phynum = 0
  elap = ElapsedMilliseconds()
  ProcedureReturn #True
EndProcedure

Procedure.i WriteTheTest()
  Protected  pa.s = GetPathPart(ProgramFilename()) + "StressTestLog_phy_" + Str(d\phy) + "_" + Str(#PB_Compiler_Version) + ".txt"
  Protected fl.i = CreateFile(#PB_Any, pa,#PB_UTF8)
  If IsFile(fl)
    WriteString(fl, d\txt, #PB_UTF8)
    CloseFile(fl)
    RunProgram(pa, "", GetPathPart(pa),#PB_Program_Open)
  EndIf
  d\txt = ""
  ProcedureReturn #True
EndProcedure

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Last edited by DK_PETER on Sat Jun 23, 2018 1:40 pm, edited 9 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Sun Jan 29, 2017 11:43 am 
Offline
User
User

Joined: Fri Mar 11, 2005 6:24 pm
Posts: 42
Location: Toronto
Yes, there is something wrong with the createcube() function. And also the physics engine is significantly slower in recent versions.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Sun Jan 29, 2017 12:18 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 727
Location: Denmark
@krix
Sorry krix. I don't think the problem is related to physics.
The example above doesn't use any physics.
Furthermore, CreateCube() can't account for massive slowdown either.
CreateCone() exhibits (almost=CreateCylinder()) the same behaviour.

Using CreateCylinder() and PB 5.51 and PB 5.60:
Creation time of 457 ms and a somewhat better framerate of 25.
Using CreateCylinder() and PB 5.43:
Creation time is 246 and 60 Fps.

Furthermore the material looks wrong in PB 5.51 and 5.60 (CreateCube()).

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Sun Jan 29, 2017 1:03 pm 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1304
you are right DK_PETER ,
v543 : 30 F/s time 296
v551 : 12 F/s time 377


but look at this: the cube in v551 have 6 submeshes. so if we make the experiment using a cube mesh saved from v543 then the difference in timing is not very big like above but the same regarding the F/S

from v543:
SaveMesh(base\ms, "cube.mesh")

then replace
base\ms = CreateCube(#PB_Any, 0.5)
with:
Add3DArchive(".", #PB_3DArchive_FileSystem)
base\ms = LoadMesh(#PB_Any, "cube.mesh")

v543 30 f/s time= 300
v551 30 f/s time= 346

especially note the difference of F/S with the above results
in fact i wish the createcube return as one submesh not 6. since the native cube is very basic and important.and used in many constructions .


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Sun Jan 29, 2017 2:04 pm 
Offline
User
User

Joined: Fri Mar 11, 2005 6:24 pm
Posts: 42
Location: Toronto
I know your example doesn't have any physics. The only reason I mentioned it because applePi discovered that there is also something wrong with the "cube generation" in the very same topic while we were testing the physics. But you're right, for whatever reason, everything got slower.


Here are my results of your test code on a AMD C50 CPU, HD 6250 GPU: I also added a sphere "version" with 8 segments and 8 rings.

Code:
                                    Creation Time         FPS              Poly


v5.43   

                      cube          1800                   5                31224
                      cone          1762                   5               124896
                    sphere          1760                   5               291424

v5.44 LTS   

                      cube          1733                   6                           
                      cone          1713                   6                 same
                    sphere          1736                   6

v5.60b   

                      cube          3928                   1
                      cone          3329                   3                 same
                    sphere          3360                   3



                     



Last edited by Krix on Fri Feb 03, 2017 11:39 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Mon Jan 30, 2017 12:31 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 24, 2007 3:15 pm
Posts: 728
Location: Germany
There was a feature request that comtois has granted by using
submeshes for the cube. The problem is, that ogre needs the
same performance for a submeshes like a normal mesh.
CreateCube() should have a parameter to decide, if it should
be one mesh or 6 submeshes.

MFG PMV


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Fri Feb 03, 2017 11:44 am 
Offline
User
User

Joined: Fri Mar 11, 2005 6:24 pm
Posts: 42
Location: Toronto
Fully agree. The createcube() function (and other primitive creation functions) should create primitives without sub meshes by default. Make sub meshes optional.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Wed Feb 22, 2017 11:02 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 727
Location: Denmark
First post updated.

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Thu Apr 12, 2018 9:39 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13326
Location: France
I finally found the issue for the perf decrease, it should be OK in the upcoming 5.70 beta :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Thu Apr 12, 2018 12:28 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 727
Location: Denmark
@Fred
You're one helluva guy!! That was some great news!
I knew you would find the problem eventually. :wink:

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Thu Apr 12, 2018 12:47 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5774
Location: Wales, UK
Needle in a haystack found 8)

Definitely though, sub-meshes should be an option, it's not just about performance.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Massive speed differences between PB versions (Windows)
PostPosted: Tue May 22, 2018 1:09 pm 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1304
hope the v5.70 will run my animated tubes here (first example):
viewtopic.php?f=36&t=67720
the same as 5.46 . in 5.62 its fps is 30 while in 5.46 the fps= 47 and apparently much more speedier even without looking at the fps numbers
the only way i can let the sphere inside the animated tubes is by calling
;line 198
CreateEntityBody(1, #PB_Entity_StaticBody , 1, 1, 1)
at least once per 4 loops of the main repeat ...until
ie before the sphere fall down to the ground the tubes is updated in this way


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye