XPAGES – Is SSJS performance loss when using @functions?

If I want to parse text fields in SSJS, there are two main tools. Built-in JavaScript code and newly converted @Functions. Is @Functions slower than using pure javascript? Or is there no real difference?

viewScope.put("length", tmpStr.length)

and

viewScope.put("length:, @Length(tmpStr))

For me, It seems that @Formula is not as fast as using SSJS code.

You can easily test with code like this (reload the page multiple times to get serious results):





var start = java. lang.System.currentTimeMillis();
var testString = "0123456789";
var dummy;
for( var i=0; i<100000; i++ ){
dummy = @Length( testString )
}
var stop = java.lang.System.currentTimeMillis();
stop-start + "ms"}]]>






var start = java.lang.System.currentTimeMillis();
var testString = "0123456789";
var dummy;
for( var i=0; i<100000; i++ ){
dummy = testString.length;
}
var stop = java.lang .System.currentTimeMillis();
stop-start + "ms"}]]>


If I want to parse text fields in SSJS, there are two main tools. Built-in JavaScript code and newly converted @Functions. @Functions is better than Is it slow to use pure javascript? Or is there no real difference?

viewScope.put("length", tmpStr.length)

and

viewScope.put("length:, @Length(tmpStr))

For me, it seems that @Formula is not as fast as using SSJS code.

You can easily test with code like this (reload the page multiple times to get serious results):





var start = java.lang.System.currentTimeMillis();
var testString = "0123456789";
var dummy;
for( var i=0; i<100000; i++ ){
dummy = @Length( testString )
}
var stop = java.lang.System.currentTimeMillis();
stop-start + "ms"}]]>






var start = java.lang.System.currentTimeMillis();
var testString = "0123456789";
var dummy;
for( var i=0; i< 100000; i++ ){
dummy = testString.length;
}
var stop = java.lang.System.currentTimeMillis();
stop-start + "ms"}] ]>


WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2615 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.