pb-event-fast

Share your advanced PureBasic knowledge/code with the community.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

pb-event-fast

Post by gurj »

Virtual table faster than Select of pb.
;TODO first, we not should use id 0 ,Example:

Code: Select all

OpenWindow(1,0,0,200,200,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
bb=ButtonGadget(0, 5,165,100, 20,"Gad0")
Debug GetDlgCtrlID_(bb);=0 function succeeds, Return id 0
Debug GetDlgCtrlID_(22);=0 function fails, also return NULL 0
;TODO  but:
Debug Bool(bb=22);=0

While WindowEvent():Wend
Repeat:ev=WaitWindowEvent():Select ev
  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End 
pb-event-fast:

Code: Select all

;pb-event-fast.pb
; by gurj
; ataorj.ys168.com
Enumeration Window
 #win1=1
 #win2
EndEnumeration
Dim Window(#PB_Compiler_EnumerationValue):Window(0)=#PB_Compiler_EnumerationValue
a=1:Window(a)=?Win1
a+1:Window(a)=?Win2

Enumeration Gadget
 #Gad1=1
 #Gad2
 #Gad3
 #Gad4
 #Gad5
EndEnumeration
Dim Gadget(#PB_Compiler_EnumerationValue):Gadget(0)=#PB_Compiler_EnumerationValue
Enumeration Gadget;TODO staticGad
 #staticGad1
 #staticGad2
EndEnumeration
a=1:Gadget(a)=?Gad1
a+1:Gadget(a)=?Gad2
a+1:Gadget(a)=?Gad3
a+1:Gadget(a)=?Gad4
a+1:Gadget(a)=?Gad5

Enumeration MenuItem
 #MenuIt1=1
 #MenuIt2
EndEnumeration
Dim MenuIt(#PB_Compiler_EnumerationValue):MenuIt(0)=#PB_Compiler_EnumerationValue
a=1:MenuIt(a)=?MenuIt1
a+1:MenuIt(a)=?MenuIt2

Enumeration PbEven
 #Event_Gadget=1
 #Event_Menu
 #Event_SysTray
 #Event_ActivateWindow=4
 #Event_WindowDrop
 #Event_GadgetDrop
 #Event_MinimizeWindow
 #Event_MaximizeWindow
 #Event_RestoreWindow
 #Event_Timer
 #Event_RightClick
 #Event_LeftClick
 #Event_LeftDoubleClick
 #Event_DeactivateWindow
 #Event_Repaint
 #Event_CloseWindow
 #Event_MoveWindow
 #Event_SizeWindow
EndEnumeration
Dim EventIt(#PB_Compiler_EnumerationValue):EventIt(0)=#PB_Compiler_EnumerationValue
; 13100=#PB_Event_Gadget
; 13101=#PB_Event_Menu
; 13102=#PB_Event_SysTray
;TODO no 13103,Event_Window use 13104
; 13104=#PB_Event_ActivateWindow
; 13105=#PB_Event_WindowDrop
; 13106=#PB_Event_GadgetDrop
; 13107=#PB_Event_MinimizeWindow
; 13108=#PB_Event_MaximizeWindow
; 13109=#PB_Event_RestoreWindow
; 13110=#PB_Event_Timer
; 13111=#PB_Event_RightClick
; 13112=#PB_Event_LeftClick
; 13113=#PB_Event_LeftDoubleClick
; 13114=#PB_Event_DeactivateWindow
; 13115=#PB_Event_Repaint
; 13116=#PB_Event_CloseWindow
; 13117=#PB_Event_MoveWindow
; 13118=#PB_Event_SizeWindow
a=1:EventIt(a)=?Event_Gadget
a+1:EventIt(a)=?Event_Menu
a+1:EventIt(a)=?Event_SysTray
a+1:EventIt(a)=?addressTop;or =?Event_ActivateWindow;no 13103,NOT use 13103
a+1:EventIt(a)=?Event_ActivateWindow
a+1:EventIt(a)=?Event_WindowDrop
a+1:EventIt(a)=?Event_GadgetDrop
a+1:EventIt(a)=?Event_MinimizeWindow
a+1:EventIt(a)=?Event_MaximizeWindow
a+1:EventIt(a)=?Event_RestoreWindow
a+1:EventIt(a)=?Event_Timer
a+1:EventIt(a)=?Event_RightClick
a+1:EventIt(a)=?Event_LeftClick
a+1:EventIt(a)=?Event_LeftDoubleClick
a+1:EventIt(a)=?Event_DeactivateWindow
a+1:EventIt(a)=?Event_Repaint
a+1:EventIt(a)=?Event_CloseWindow
a+1:EventIt(a)=?Event_MoveWindow
a+1:EventIt(a)=?Event_SizeWindow

; Gadgettype Gadget 支持事件类型不连续, 不均匀等原因, 不适合使用虚拟表, 这里没有虚拟表。
;GadgetEventType Gadget to EventType support discontinuous, not uniform and other reasons, not suitable for the use of virtual tables, here is no virtual table.
; 0=#PB_EventType_LeftClick
; 1=#PB_EventType_RightClick
; 2=#PB_EventType_LeftDoubleClick
; 3=#PB_EventType_RightDoubleClick:
; 14000=#PB_EventType_Focus
; 14001=#PB_EventType_LostFocus
; 14002=#PB_EventType_DragStart
; 768=#PB_EventType_Change

win1=OpenWindow(#win1,0,0,200,190,"win1",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(#Gad1, 0, 0,200, 100)
SetGadgetText(#Gad1, ~"Gad1\nplease LeftClick Gad3\nRightClick image and Item1\nRightClick Window's blank or staticGad")
FrameGadget(#staticGad1, 0,  108, 110, 80, "staticGad1")
TextGadget(#staticGad2, 5,125,100, 20,"staticGad2")
StringGadget(#Gad2, 5,145,100, 20,"Gad2")
ButtonGadget(#Gad3, 5,165,100, 20,"Gad3")
win2=OpenWindow(#win2,WindowX(#win1)-150,WindowY(#win1),150,180,"win2",#PB_Window_SystemMenu)
image=LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\PureBasic.bmp")

ImageGadget(#Gad4, 5,5,20, 20,image)
CreatePopupMenu(1)
MenuItem(1, "Item1:create #Gad5")
MenuItem(2, "Item2:create Gad 15")

While WindowEvent():Wend
EnableASM
gadgad=Gadget(0)+1

addressTop:;Repeat
ev=WaitWindowEvent()
If ev>13099 And ev<13119
 addre=EventIt(ev-13099)
 jmp addre
 Else:Select ev
  Case #WM_LBUTTONDOWN
 EndSelect
EndIf
Goto addressTop ;ForEver
addressEnd:
;kay add code

End

Event_Gadget:
eg=EventGadget()
If eg<gadgad ;all Gadget not use 0
addre=Gadget(eg)
jmp addre
Else
 Goto addressTop
EndIf
;TODO {优化方法:不想处理Gad1,Gad2事件时可这样:
;Optimization method: This can be done when you do not want to handle Gad1,Gad2 events:
Gad1:
Gad2:
;TODO ?Gad1=?Gad2}
Goto addressTop
Gad3:
Debug "Gad3"
Goto addressTop
;Gad5 will created by exe runing
Gad5:
Debug "Gad5"
Goto addressTop
Gad4:
Debug "Gad4"
If EventType()=#PB_EventType_RightClick
 DisplayPopupMenu(1, win2)
EndIf
Goto addressTop

Event_Menu:
; TODO {MenuIt仅一个时还可优化,删除开始:
;MenuIt only one time can also be optimized to delete the start:
addre=MenuIt(EventMenu())
jmp addre
MenuIt1:
Debug "MenuIt1"
ButtonGadget(#Gad5, 5,100,100, 20,"Gad5")
Goto addressTop
MenuIt2:
;}删除结束
;EndDelete
;then has this...:
Debug "MenuIt2"
ButtonGadget(15, 5,130,100, 20,"Gad 15")
Goto addressTop

Event_ActivateWindow:
addre=Window(EventWindow())
jmp addre
Win1:
Debug "Win1"
Goto addressTop
Win2:
Debug "Win2"
Goto addressTop
Event_RightClick:
Debug "Window's blank or staticGad RightClicked"
Goto addressTop
Event_CloseWindow:
Goto addressEnd

;TODO 不处理的事件优化为合并:
; Events that are not handled are optimized to merge.
Event_SysTray:
Event_WindowDrop:
Event_GadgetDrop:
Event_MinimizeWindow:
Event_MaximizeWindow:
Event_RestoreWindow:
Event_Timer:
Event_LeftClick:
Event_LeftDoubleClick:
Event_DeactivateWindow:
Event_Repaint:
Event_MoveWindow:
Event_SizeWindow:
Goto addressTop
; TODO {不处理的事件优化为更彻底的合并:
;Events that are not handled are optimized for more thorough consolidation.
;del:
; Gad1:
; Gad2:
; Goto addressTop
; [To changed:
; Gadget(1)=?addressTop
; Gadget(2)=?addressTop
; }

; IDE Options = PureBasic 5.71 beta 1 LTS (Windows - x86)
; CursorPosition = 14
; Folding = -
; EnableXP
; DPIAware
; Watchlist = addre
 
Last edited by gurj on Wed Apr 24, 2019 6:37 pm, edited 4 times in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

why do i currently use Goto ?

first see Select's doc:
Select provides the ability to determine a quick choice. The program will execute the <expression1> and retain its' value in memory. It will then compare this value to all of the Case <expression> values and if a given Case <expression> value is true, it will then execute the corresponding code and quit the Select structure. Case supports multi-values and value ranges through the use of the optional To keyword (numeric values only). If none of the Case values are true, then the Default code will be executed (if specified).

then see pb all Event,they are continual(no 13103):
13100=#PB_Event_Gadget
13101=#PB_Event_Menu
13102=#PB_Event_SysTray
no 13103,Event_Window use 13104
13104=#PB_Event_ActivateWindow
13105=#PB_Event_WindowDrop
13106=#PB_Event_GadgetDrop
13107=#PB_Event_MinimizeWindow
13108=#PB_Event_MaximizeWindow
13109=#PB_Event_RestoreWindow
13110=#PB_Event_Timer
13111=#PB_Event_RightClick
13112=#PB_Event_LeftClick
13113=#PB_Event_LeftDoubleClick
13114=#PB_Event_DeactivateWindow
13115=#PB_Event_Repaint
13116=#PB_Event_CloseWindow
13117=#PB_Event_MoveWindow
13118=#PB_Event_SizeWindow

WindowEvent() Include pbEvent and Api Event, if use this:
Select Event
case ...
...
case ...
EndSelect

will exist much :
compare this value[any Event] to all of the Case <expression> values, until has Case is true.
this is very bad !!!!

pbEvent are continual, should use virtual tables, this need use Goto.
also see:
How to understand GoTo's document note?
viewtopic.php?f=13&t=72693
my pb for chinese:
http://ataorj.ys168.com
User avatar
GedB
Addict
Addict
Posts: 1312
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Re: pb-event-fast

Post by GedB »

Interesting. Have you got any benchmarks to show the performance impact?
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

No, I just think that my logical thinking is right.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

Using virtual tables, you do not need to compare and select events to jump directly to the processing address of the event.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

Updated, on a small blunder to fixed.
my pb for chinese:
http://ataorj.ys168.com
User avatar
GedB
Addict
Addict
Posts: 1312
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Re: pb-event-fast

Post by GedB »

gurj wrote:No, I just think that my logical thinking is right.
When optimising code the outcome can be counter-intuitive. You don't know until you have the benchmark numbers.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

The comments were updated and translated into English.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

GedB wrote:
gurj wrote:No, I just think that my logical thinking is right.
When optimising code the outcome can be counter-intuitive. You don't know until you have the benchmark numbers.
You are right and should provide validation.
I'm not good at this validation, so I just do what I think is right.
One thing that is similar is that if someone explicitly denies me, he also needs to have clear proof.
If none of us can deny each other, I certainly still maintain my point of view.
However, I thought about it, I have the verification method, is by comparing the execution time to verify.
I'm here 1:23, and I'm going to take a break, maybe after 10:00, I or someone has provided the verification code.
my pb for chinese:
http://ataorj.ys168.com
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: pb-event-fast

Post by mk-soft »

I'm sorry,
but I don't like GOTO.
I find it better to solve it via virtual tables.
You can also work with prototypes and call the required direct with an array over the index (Enumeration of Menus and Gadget).

I use this method with virtual tables for a long time in my EventDesigner.

Part of automatic created code of EventDesigner

Code: Select all

;-TOP

; Event Designer - EventMain (Do Not Edit - Allways Overwrite)

; *********************************************************************************************************

; Init Event Pointer

Prototype MyProtoInvoke()

Structure udtCallEvent
  Invoke.MyProtoInvoke[0]
EndStructure

Global *CallEventMenu.udtCallEvent = ?CallEventMenu
Global *CallEventGadget.udtCallEvent = ?CallEventGadget
Global *CallEventSize.udtCallEvent = ?CallEventSize
Global *CallEventExit.udtCallEvent = ?CallEventExit

#CallEventMenuCount = 3
#CallEventGadgetCount = 4
#CallEventWindowCount = 1

; *********************************************************************************************************

Procedure MyEventMenu()
  Protected MenuID = EventMenu()
  Select MenuID
    Case 0 To #CallEventMenuCount - 1
      *CallEventMenu\Invoke[MenuID]()
    ; Begin MacMenus
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS  
      Case #PB_Menu_About
        EventMenu_MacAbout()
      Case #PB_Menu_Preferences
        EventMenu_MacPreferences()
      Case #PB_Menu_Quit
        EventMenu_MacQuit()
    CompilerEndIf
    ; End MacMenus
  EndSelect
EndProcedure

; *********************************************************************************************************

Procedure MyEventGadget()
  Protected GadgetID = EventGadget()
  Select GadgetID
    Case 0 To #CallEventGadgetCount - 1
      *CallEventGadget\Invoke[GadgetID]()
  EndSelect
EndProcedure

; *********************************************************************************************************

Procedure MyEventSize()
  Protected WindowID = EventWindow()
  Select WindowID
    Case 0 To #CallEventWindowCount - 1
      *CallEventSize\Invoke[WindowID]()
  EndSelect
EndProcedure

; *********************************************************************************************************

Procedure MyEventExit()
  Protected WindowID = EventWindow()
  Select WindowID
    Case 0 To #CallEventWindowCount - 1
      *CallEventExit\Invoke[WindowID]()
  EndSelect
EndProcedure

; *********************************************************************************************************

Procedure MyEventDispatch()
  ; Do nothing
EndProcedure

; *********************************************************************************************************

DataSection
  CallEventMenu:
    Data.i @EventMenu_Main_MenuItem_Open()
    Data.i @EventMenu_Main_MenuItem_Save()
    Data.i @EventMenu_Main_MenuItem_Exit()
  CallEventGadget:
    Data.i @EventGadget_Main_Calendar_0()
    Data.i @EventGadget_Main_Button_0()
    Data.i @EventGadget_Main_Button_1()
    Data.i @EventGadget_Main_Button_2()
  CallEventSize:
    Data.i @EventSize_Main()
  CallEventExit:
    Data.i @EventExit_Main()
EndDataSection

; *********************************************************************************************************
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
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

thanks mk-soft !
I'm going to learn your code.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

;verify Example use virtual tables
;suppose only handling :
;#PB_Event_Gadget,#PB_Event_Menu,#PB_Event_CloseWindow
;has 1-20 Gadget,suppose only handling 1-10
;has 1-10 MenuItem,suppose handling 1-10

Code: Select all

Dim EventIt(19):EventIt(0)=19
a=1:EventIt(a)=?Event_Gadget
a+1:EventIt(a)=?Event_Menu
a+1:EventIt(a)=?addressTop;Event_SysTray
a+1:EventIt(a)=?addressTop;or =?Event_ActivateWindow;no 13103,NOT use 13103
a+1:EventIt(a)=?addressTop;Event_ActivateWindow
a+1:EventIt(a)=?addressTop;Event_WindowDrop
a+1:EventIt(a)=?addressTop;Event_GadgetDrop
a+1:EventIt(a)=?addressTop;Event_MinimizeWindow
a+1:EventIt(a)=?addressTop;Event_MaximizeWindow
a+1:EventIt(a)=?addressTop;Event_RestoreWindow
a+1:EventIt(a)=?addressTop;Event_Timer
a+1:EventIt(a)=?addressTop;Event_RightClick
a+1:EventIt(a)=?addressTop;Event_LeftClick
a+1:EventIt(a)=?addressTop;Event_LeftDoubleClick
a+1:EventIt(a)=?addressTop;Event_DeactivateWindow
a+1:EventIt(a)=?addressTop;Event_Repaint
a+1:EventIt(a)=?addressEnd;Event_CloseWindow
a+1:EventIt(a)=?addressTop;Event_MoveWindow
a+1:EventIt(a)=?addressTop;Event_SizeWindow

Macro address(Type,Item)
 Type#It(Item)=?Type#It#Item
EndMacro

Dim GadIt(10):GadIt(0)=10
gadgad=11
address(Gad,1)
address(Gad,2)
address(Gad,3)
address(Gad,4)
address(Gad,5)
address(Gad,6)
address(Gad,7)
address(Gad,8)
address(Gad,9)
address(Gad,10)

Dim MenuIt(10):MenuIt(0)=10
address(Menu,1)
address(Menu,2)
address(Menu,3)
address(Menu,4)
address(Menu,5)
address(Menu,6)
address(Menu,7)
address(Menu,8)
address(Menu,9)
address(Menu,10)

EnableASM

q.q=ElapsedMilliseconds()
ev=13000
n=0
addressTop:;Repeat
ev+1
If ev=14000:n+1
ev=13000:EndIf; imitation ApiEvent when ev=13000 to 13099 and ev=13119 to 14000

If ev>13099 And ev<13119
 addre=EventIt(ev-13099)
 jmp addre
 Else:Select ev
  Case #WM_LBUTTONDOWN
 EndSelect
EndIf

Goto addressTop;ForEver
addressEnd:

If n<10000:Goto addressTop:EndIf
   ;TODO out:
;    Debug b;my pc =-251
;    Debug ElapsedMilliseconds()-q;my pc =8521
      q=ElapsedMilliseconds()-q
   MessageRequester("","b="+b+~"\ntime="+q)
End

;pb_Event
Event_Gadget:
    eg+1;=Random(20,1)
  If eg>20
  eg=1:EndIf
If eg<gadgad ;all Gadget not use id 0
 addre=GadIt(eg)
 jmp addre
Else
 Goto addressTop
EndIf

GadIt1:
b+1
Goto addressTop
GadIt2:
b-1
Goto addressTop
GadIt3:
b+1
Goto addressTop
GadIt4:
b-1
Goto addressTop
GadIt5:
b+1
Goto addressTop
GadIt6:
b-1
;TODO test :
;Debug "GadIt 6"
Goto addressTop
GadIt7:
b+1
Goto addressTop
GadIt8:
b-1
Goto addressTop
GadIt9:
b+1
Goto addressTop
GadIt10:
b-1
Goto addressTop

Event_Menu:
  mi+1;=Random(10,1)
  If mi>10
  mi=1:EndIf
addre=MenuIt(mi)
jmp addre
MenuIt1:
b+1
Goto addressTop
MenuIt2:
b-1
Goto addressTop
MenuIt3:
b+1
Goto addressTop
MenuIt4:
b-1
Goto addressTop
MenuIt5:
b+1
Goto addressTop
MenuIt6:
b-1
;TODO test:
;Debug "MenuIt 6"
Goto addressTop
MenuIt7:
b+1
Goto addressTop
MenuIt8:
b-1
Goto addressTop
MenuIt9:
b+1
Goto addressTop
MenuIt10:
b-1
Goto addressTop
; IDE Options = PureBasic 5.71 beta 1 LTS (Windows - x86)
; CursorPosition = 5
; FirstLine = 3
; Folding = --
; EnableXP
; DPIAware
; DisableDebugger

;verify Example use Select
;suppose only handling :
;#PB_Event_Gadget,#PB_Event_Menu,#PB_Event_CloseWindow
;has 1-20 Gadget,suppose only handling 1-10
;has 1-10 MenuItem,suppose handling 1-10

Code: Select all

q.q=ElapsedMilliseconds()
ev=13000
n=0
addressTop:;Repeat
ev+1
If ev=14000:n+1
ev=13000:EndIf; imitation ApiEvent when ev=13000 to 13099 and ev=13119 to 14000

Select ev
 Case #PB_Event_Gadget
  ;eg=Random(20,1)
    eg+1;=Random(20,1)
  If eg>20
  eg=1:EndIf
  Select eg
   Case 1
    b+1
   Case 2
    b-1
   Case 3
    b+1
   Case 4
    b-1
   Case 5
    b+1
   Case 6
    b-1
    ;TODO test:
    ;Debug "MenuIt 6"
   Case 7
    b+1
   Case 8
    b-1
   Case 9
    b+1
   Case 10
    b-1
  EndSelect
 Case #PB_Event_Menu
  mi+1;=Random(10,1)
  If mi>10
  mi=1:EndIf
  Select mi
   Case 1
    b+1
   Case 2
    b-1
   Case 3
    b+1
   Case 4
    b-1
   Case 5
    b+1
   Case 6
    b-1
    ;TODO test:
    ;Debug "GadIt 6"
   Case 7
    b+1
   Case 8
    b-1
   Case 9
    b+1
   Case 10
    b-1
  EndSelect
 Case #PB_Event_CloseWindow
  If n>9999
   ;TODO out:
   q=ElapsedMilliseconds()-q
   MessageRequester("","b="+b+~"\ntime="+q)
;    Debug b;my pc =-134
;    Debug ;my pc =8487
  End:EndIf
 Case #WM_LBUTTONDOWN
EndSelect

Goto addressTop;ForEver
addressEnd:
Last edited by gurj on Wed Apr 24, 2019 6:42 pm, edited 1 time in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb-event-fast

Post by gurj »

use virtual tables out:
Debug b;my pc =-251
Debug ElapsedMilliseconds()-q;my pc =8521

use Select out:
Debug b;my pc =-134
Debug ElapsedMilliseconds()-q;my pc =8487

why is this ?...
why has 251-134=117 ?...
my pb for chinese:
http://ataorj.ys168.com
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: pb-event-fast

Post by Little John »

gurj wrote:I'm not good at this validation, so I just do what I think is right.
One thing that is similar is that if someone explicitly denies me, he also needs to have clear proof.
Once upon a time, there was an agreement among serious people that someone who claimed something had to prove that her/his statement was correct.
gurj wrote:If none of us can deny each other, I certainly still maintain my point of view.
In "modern times," many people (including the current president of a large country) like to do it the other way around: Just claim something that fits your view of the world, and then wait and see if anyone else can prove it wrong.
By the way, did you know that green-and-white striped goats live on the back of Mars? As long as nobody proves otherwise, I think I'm right. :lol: :lol:
gurj wrote:Debug ElapsedMilliseconds()-q;my pc =8521
Has already been mentioned here on the forum that time measurement only makes sense when the debugger is switched off?
Last edited by Little John on Wed Apr 24, 2019 7:45 am, edited 1 time in total.
User avatar
GedB
Addict
Addict
Posts: 1312
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Re: pb-event-fast

Post by GedB »

gurj wrote: You are right and should provide validation.
Hi Gurj,

It isn’t about verification or validation. It’s about exploration.

You start with your hypothesis - the thinking you believe is correct - and look for ways to explore that hypothesis by trying something and seeing what the results are.

This is the process of engineering.

There is always so much to learn. When it comes to optimisation you can discover the impact of things like compiler optimisation and CPU cacheing.

Consider, for example, this discussion on how using goto impacts an optimising compilers ability to construct a flow graph: https://stackoverflow.com/questions/103 ... timization

Is that relevant within Purebasic? Maybe Fred will tell us? Perhaps you can find out with a little experimentation.

Regards,


Ged


Sent from my iPhone using Tapatalk
Post Reply