Question
· Feb 1, 2018

Performance in Cache ObjectScript

Hi Guys,

Can you please advise on the below queries. 

Query 1:

Example 1:

 S a="345",b="arun",c="kumar",d="hi",e="yello",f="orange"

Example 2:

S a="345"

S b="arun"

S c="kumar"

S d="hi"

S e="yello"

S f="orange"

Can you please advise me, which one is performance wise is better. 

Query 2:

Example 1:

S:a=1 R="Arun"

Example 2:

I a=2 R="Arun"

Please advise me, which one is giving better performance in this. 

Any lead would be appreciated. 

Thanks,

Arun Kumar Durairaj. 

Discussion (11)3
Log in or sign up to continue

On my desktop quite other results.

  N,j,time

  N=1e8

  j=1,2/*,3,4,5*/ {
    j,") "

    time=$zh
    d @("j"_j)(N)
    w $zh-time," s.",!
  }
  q
j1(N) public {
  i=1:1:{(a,b,c,d,e,f)=0}
}
j2(N) public {
  i=1:1:{a=0,b=0,c=0,d=0,e=0,f=0}
}
j3(N) public {
  i=1:1:{a=0,b=1,c=2,d=3,e=4,f=5}
}
j4(N) public {
  i=1:1:{a=0 b=1 c=2 d=3 e=4 f=5}
}
j5(N) public {
  i=1:1:{s $lb(a,b,c,d,e,f)=$lb(0,1,2,3,4,5)}
}

Results:

USER>^perf
1) 11.814189 s.
2) 4.683832 s.

As you can see the difference is almost 2.5 times.

https://community.intersystems.com/post/apm-finding-expensive-parts-your...

also describes how to locate expensive points in your code.

In this case you are talking about tiny differences. If this is executed millions of times in  a common path  that is executed frequently you might want to  think about it, but  for most applications it is not an issue. Those SQL queries that don't use an index are the killers.

To answer your question via timed tests:

Query 1 (Iterating 100 million times...) :

Example 1 :

w $ZTS F i=1:1:100000000 {S a="345",b="arun",c="kumar",d="hi",e="yello",f="orange"} w !,$ZTS                                                              
64708,68916.71
64708,68926.342
~9.632 secs

Example 2

w $ZTS F i=1:1:100000000 {S a="345" s b="arun" s c="kumar" s d="hi" s e="yello" s f="orange"} w !,$ZTS                                                    
64708,68900.72
64708,68910.376 
~ 9.656 secs

Query 2 (Iterating 1 billion times!!!): 

Example 1:

w $ZTS F i=1:1:1000000000 {S:a=1 R="Arun"} w !,$ZTS                       
64708,69223.394
64708,69246.773
~ 23.379 secs

Example 2:

w $ZTS F i=1:1:1000000000 {I a=2 S R="Arun"} w !,$ZTS
64708,69264.946
64708,69289.174
~ 24.228 secs 

@  Vitaliy Serdtsev (100 million iterations)

w $ZTS F i=1:1:100000000 {s (a,b,c)=0} w !,$ZTS
64708,69571.214
64708,69577.797
~6.583 secs
w !,$ZTS F i=1:1:100000000 {s a=0,b=0,c=0} w !,$ZTS
64708,69589.118
64708,69595.433
~6.315 secs
w !,$ZTS F i=1:1:100000000 {s a=0 s b=0 s c=0} w !,$ZTS
64708,69793.562
64708,69799.545
~ 5.983

As everyone said, setting variables/ conditional statements is probably not where it's getting slow. As someone mentioned PERFMON is a great tool . Another one is ^%SYS.MONLBL. 

I just got too much bloody time ....