I have a question about performance. I have a modu...
# suitescript
s
I have a question about performance. I have a module that is getting pretty large. There's a function I use in most of my script 'isNullorEmpty", thus , I'm including the module in almost all the scripts. Does Netsuite import/loan the module each and every time ?
b
it might not actually read the file from the file system every time
there have been enough caching problems to suggest that the file contents are stored in memory
but the contents of the file will certainly be evaluated each time
m
What is the value of an isNullOrEmpty function vs
if(! foo)
?
s
there is little to no value to such a function, imho
I suspect folks write utilities like that because of seeing them in other languages or due to a lack of familiarity with falsey values in JS or modern operators like
??
or
?.
e.g. C# IsNullOrEmpty()
<rant>what's worse, is each clever author of a JS
IsNullOrEmpty()
has their own definition of what 'empty' means so you have to read the implementation and understand it rather than just knowing the JS language rules. </rant>
if you're set on using such utilities, at least folks could pick something well known and documented and unit tested and battle tested by many developers (e.g. lodash)
I should note @Simon, not a rant against you or anyone for that matter! just sharing my frustration with seeing these home-grown utilities used over and over again. Usually with little gain, sometimes with actual bugs and they were harmful.
s
My question is not about the function, the module has over 30 functions, my question is about performance, will it read / import / load the file each and everytime and will it slow down.
b
the answer is yes, but not in a way that matters
the performance of your script will not be dictated by if it has to evaluate your 1 function vs 30 functions
honesty, you would probably have problems measuring any performance difference
s
Great. That's what I was looking for. Thanks