Created
April 14, 2021 09:55
-
-
Save grongierisc/85dccbc573e2ad48cea2809ac80fc062 to your computer and use it in GitHub Desktop.
Benchmark Routine vs ClassMethod vs Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Description | |
Class PackageName.ClassName Extends %RegisteredObject | |
{ | |
/// Description | |
ClassMethod Test() As %Status | |
{ | |
Set sc = $$$OK | |
#define posix ##class(%Library.PosixTime).CurrentTimeStamp() | |
Set me = ..%New() | |
set timeIn = $$$posix | |
Do me.MethodParam("HelloWorld") | |
set time = $$$posix-timeIn | |
zw " me.MethodParam(""HelloWorld"") ="_time | |
set timeIn = $$$posix | |
Do me.Method() | |
set time = $$$posix-timeIn | |
zw " me.Method() ="_time | |
set timeIn = $$$posix | |
Do ..MethodNameParam("HelloWorld") | |
set time = $$$posix-timeIn | |
zw " ..MethodNameParam(""HelloWorld"") ="_time | |
set timeIn = $$$posix | |
Do ..MethodName() | |
set time = $$$posix-timeIn | |
zw " ..MethodName() ="_time | |
set timeIn = $$$posix | |
Do LabelParam("HelloWorld") | |
set time = $$$posix-timeIn | |
zw " LabelParam(""HelloWorld"") ="_time | |
set timeIn = $$$posix | |
Do Label | |
set time = $$$posix-timeIn | |
zw " Label ="_time | |
set timeIn = $$$posix | |
do RoutineParam^Test("HelloWorld") | |
set time = $$$posix-timeIn | |
zw " RoutineParam^Test(""HelloWorld"") ="_time | |
set timeIn = $$$posix | |
do Routine^Test() | |
set time = $$$posix-timeIn | |
zw " Routine^Test() ="_time | |
Return sc | |
Label | |
set var = "HelloWorld" | |
LabelParam(param) | |
set var = param | |
} | |
/// Without parameters | |
ClassMethod MethodName() As %Status | |
{ | |
Set sc = $$$OK | |
set var = "HelloWorld" | |
Return sc | |
} | |
/// Description | |
ClassMethod MethodNameParam(param As %String) As %Status | |
{ | |
Set sc = $$$OK | |
set var = param | |
Return sc | |
} | |
/// Description | |
Method Method() As %Status | |
{ | |
Set sc = $$$OK | |
set var = "HelloWorld" | |
Return sc | |
} | |
/// Description | |
Method MethodParam(param As %String) As %Status | |
{ | |
Set sc = $$$OK | |
set var = param | |
Return sc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment