Platforms to show: All Mac Windows Linux Cross-Platform

/Main/Timer Benchmark


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: /Main/Timer Benchmark

This example is the version from Sun, 17th Mar 2012.

Project "Timer Benchmark.xojo_binary_project"
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" if rt.count/count>rt.maximum then rt.maximum = rt.count/count if nt.count/count>nt.maximum then nt.maximum = nt.count/count if ct.count/count>ct.maximum then ct.maximum = ct.count/count StaticText14.text = Format(rt.maximum,"0")+" events per second" StaticText13.text = Format(nt.maximum,"0")+" events per second" StaticText12.text = Format(ct.maximum,"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
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control StaticText12 Inherits Label
ControlInstance StaticText12 Inherits Label
End Control
Control StaticText13 Inherits Label
ControlInstance StaticText13 Inherits Label
End Control
Control StaticText14 Inherits Label
ControlInstance StaticText14 Inherits Label
End Control
Control StaticText17 Inherits Label
ControlInstance StaticText17 Inherits Label
End Control
Control StaticText18 Inherits Label
ControlInstance StaticText18 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
Property maximum 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
Property maximum 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 PeriodSeconds = 0.000001 mode = 2 End Sub
Property count As Integer
Property maximum As Integer
End Class
End Project

See also:

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


The biggest plugin in space...