Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Empty lines and performance?
Collapse
X
-
Never ever worry about blank lines or comments. Period. Full Stop.Originally posted by elliot5 View PostDoes having a large percentage of empty lines or // out code reduce script reading time / performance? I am 17,000 lines deep but could reduce that by compressing the script considerably if it would help performance.
17,000 lines, with a significant portion of them as comments (as you imply),
is nothing to the compiler. It will run through these lines like a hot knife
through butter.
If you think you need speed improvements, consider a faster computer, or
at least a faster hard drive, or even a RAM disk. I seriously doubt you'd
ever detect much speed improvement from any compiler by reducing the
number of comments or blank lines.
- Likes 2
Comment
-
Meaningful comments and good layout of the code in the editor are good things. They enhance code maintenance and readability. As others have mentioned, the compiler will not "think twice" about such things. I have more than 100K lines of (I believe) well-documented code and a few extra seconds of compilation time is worth every comment!
Performance, on the other hand, is a run-time thing we always need to consider when engineering software. Hardware will sometimes be relevant, but often, it is what we have programmed that has the most effect on increasing/decreasing performance.
Some things to consider include:- Understand how different language features and constructs affect performance -- the same functionality can often be achieved using different language elements, sometimes with dramatically different performance outcomes
- Understand the logic of the function being performed and structure the code to avoid performance-intensive code unless it is necessary to execute it
- Look for ways to "simplify" code that becomes "cumbersome" after multiple development edits -- refactoring is your friend ... in most cases!
- Check "loop" code (i.e. for, foreach, while, do, etc) to ensure only as many iterations as needed are performed -- continue and break are useful to shorten such iterative cycles when certain conditions are met
- Structure data to avoid unnecessary memory usage -- e.g. don't declare sparse arrays unless the functionality requires it
- Dispose! When finished with something, always use any disposing capabilities in the language for the constructs used. When done with things that do not explicitly dispose, set variables with structure (e.g. arrays) to null to improve garbage collection.
Good luck with the programming, and many profitable trades for you.
- Likes 2
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment