Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Timer Benchmark
Function:
Required plugins for this example: MBS MacCF Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Timer Benchmark
This example is the version from Sun, 23th Sep 2017.
Project "Timer Benchmark.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() count = 0 CheckTimer.Period = 1000 CheckTimer.mode = 2 End EventHandler
End Control
Control CheckTimer Inherits Timer
ControlInstance CheckTimer Inherits Timer
EventHandler Sub Action() if count = 0 then nt = new MyNSTimer ct = new MyCarbonTimer rt = new MyRBTimer Counting = true else StaticText6.text = Format(rt.count/count,"0")+" events per second" StaticText5.text = Format(nt.count/count,"0")+" events per second" StaticText4.text = Format(ct.count/count,"0")+" events per second" end if count = count +1 End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Property CT As MyCarbonTimer
Property NT As MyNSTimer
Property RT As MyRBTimer
Property Untitled As Integer
Property count As Integer
Property mode As Integer
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSTimer Inherits NSTimerMBS
EventHandler Sub Action() if Counting then count = count +1 end if End EventHandler
Sub Constructor() // Calling the overridden superclass constructor. // Note that this may need modifications if there are multiple constructor choices. // Possible constructor calls: // Constructor(fireDate As date, timeInterval As double, repeats As boolean) -- From NSTimerMBS // Constructor(timeInterval As double, repeats As boolean) -- From NSTimerMBS Super.Constructor(0.000001, true) End Sub
Property count As Integer
End Class
Class MyRBTimer Inherits Timer
EventHandler Sub Action() if Counting then count = count +1 end if End EventHandler
Sub Constructor() Period = 0 mode = 2 End Sub
Property count As Integer
End Class
Module Util
Property Counting As Boolean
End Module
Class MyCarbonTimer Inherits CarbonEventsTimerMBS
EventHandler Sub Action() if Counting then count = count +1 end if End EventHandler
Sub Constructor() // Calling the overridden superclass constructor. Super.Constructor // Period = 1 // 1ms PeriodSeconds = 0.000001 mode = 2 End Sub
Property count As Integer
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCocoa Plugin.




Links
MBS FileMaker blog