Skip to content

Instantly share code, notes, and snippets.

@grongierisc
Created April 14, 2021 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grongierisc/85dccbc573e2ad48cea2809ac80fc062 to your computer and use it in GitHub Desktop.
Save grongierisc/85dccbc573e2ad48cea2809ac80fc062 to your computer and use it in GitHub Desktop.
Benchmark Routine vs ClassMethod vs Method
/// 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