bi_mg 7 Posted September 14, 2021 (edited) Hello mission builders, scripters and developers, I like to introduce my project that is called a3-lib-checks on GitHub. I realy hope it useful for some of you. It is a kind of a BETA VERSION! Your tests in mission runtime envionment are very welcome 🙂. Link to Repository: https://github.com/DevMBeyer/a3-lib-checks Link to Unit tests: https://devmbeyer.github.io/a3-lib-checks/reports/index.html (supplement) TABLE OF CONTENT What these Libraries do The Usage of my libraries My Intension to write these libraries Why I used macro functions My research My conclusion Loops Conditions Lazy Evaluations Declarations Scopes Brackets Copy not everything How do I develop Unit Tests My Problems Test Cases Common Naming's Upload my Repository Website Entrypoint Bugs Feedback Apologizes CONTENT What these Libraries do This project contains several libraries with macro functions in it to enhanced data validation in Arma 3 scripts. The Macros are very system performance developed and should be easy to use. The functions in libraries are thematically and technically ordered. The aim of this project is to make data validation easier for other scripters and myself. Some Macros are a little confusing for you on how to work with them e.g. MB_IS_NIL( ARG ) which is nothing but isNil {ARG }. Nothing really useful but it has to be in the list of structure of macro functions for formality in my opinion. The Usage of libraries They are extremely useful for debugging a script or for conditions in mission runtime in my opinion. It should pull down the system performance in very little, so it is a good thing I guess. It depends on macro of course. My Intension to write these libraries While I was working on my SQF Scripts, I was often stuck with a bunch of errors. So I decided to developed a validation functions, which cost less system performance. As I said, it depends on the function of course. Why I used macro functions Macros must be imported from scripts, they can’t be present itself as script functions. But complex Macro functions are little faster as they are imported as code and not as a reference to the extern code. Later before the release, I will extract the string characters which are not functional like spaces between expressions. Therefor it runs little little little bit faster I hope. My research I tested with diag_performCode every single command or code construct I will work with, which is the fastest. My conclusion It is only my very personal conclusion below on the results of diag_performCode Loops I do not use for-, while- forEach-Loop. forEach loops brings more variables with them like _forEachIndex for example and decrease the system performance. In nearly all cases I don't need to use these variables, so findIf is the goal I found out. It only brings _x with it. It is really faster but it is really confusing because of the complexity. E.g. /* CODE */ \ private _copy = +ARR; \ ( ( _copy findIf { \ private _elem = ARR deleteAt 0; \ !( \ ( TYPES findIf { \ /* CONDITION */ \ } ) isEqualTo -1 \ ) \ } \ } ) isEqualTo -1 ) \ /* CODE */ \ Conditions The if-then-else should be slower than if-exitWith-expression. But both condition constructions do the same thing. // slower if ( CONDITION ) then { STATEMENT_1 } else { STATEMENT_2 }; // faster if ( CONDITION ) exitWith { STATEMENT_1 }; STATEMENT_2 Lazy Evaluations https://community.bistudio.com/wiki/Code_Optimisation#Lazy_evaluation The complex nested conditions are much faster than any other condition constructions like ifs, switch-cases. It depends on how to use them of course. false and true and true and true // slower false and { true and { true and { true } } } // faster Declarations I used as less declarations as possible and found out which the best performance is on declaration is – I guess. [] params [ [ "_foo", 0 ],[ "_bar", 0 ] ] // is little slower private _foo = 0; private _bar = 0; // is faster scopes The declaration private [ "_fnc" ]; _fnc = {}; is slowest as private _fnc = {} but if you declare this recursive function 10000 times, it is really useful and faster when you combine needed function scope to check n nested array as an argument. If the condition is matched in this function with the call 1000 times, the function just breaks out with the return and will not needto level up 1000 times to the first function call. But I am not sure of the results: private [ "_fnc" ]; scopeName "recursive"; _fnc = { /* CODE */ if( (CONDITION) call _fnc ) exitWith { true }; false breakout "recursive" }; ARG call _fnc; this function does not do anything but I hard coded to show what I means. Brackets I used brackets anywhere to enclose an expression like (_a+_b). The interpreter should like brackets, because he mustn’t search were the expression ends and prioritize which expression gets first. Again, it is my conclusion on the test results. ARR select 0 select 1 isEqualTo 0 // slower ( ( ( ARR select 0 ) select 1 ) isEqualTo 0 ) // faster Copy not everything I referenced not all Macro functions because they are sometimes dumplicates on commands in both functions so I must develop by foot e.g. MB_COMPARE_ARRAY_SIZE( ARR, 1 ) or { MB_COMPARE_ARRAY_SIZE( ARR, 2 ) } It is compact and more readable but both functions checks nil and array first, and that’s exaggerated. So I’ decided to solve this way on foot. !isNil{ARR} \ and { \ ( ARR isEqualType [] ) \ and { private _cnt = count ARR; \ (_cnt isEqualTo 1) \ or { _cnt isEqualTo 2 } \ } \ } \ I want only show what I mean. How do I develop I used my tag `MB` nearly everywhere in the code, therefore shouldn't be any name conflicts in the namespaces. I adopted BI Code Comments style in general with individualities I used K&R Code style My code should be well documented so far (if you leave out my grammar). Therefore the script comments should be understandable. Unit Tests I've written test cases and tested them with simple Unit Tests for every single macro function. Every Test Results from unit tests is generated as a report. You can see the reports of test results which were generated in html code. Unit test case arguments were changed, deleted, or expanded throughout the test by me. The reason: I have to correct individual test cases to show the differences in the individual test results. My Problems Test Cases I have optimized test cases and test arguments, while I tested each macro function to each test case. Meanwhile between past and now there are partly different and extended test arguments in unit test cases. It can be seen in the different unit test files and reports. I didn't write the test arguments to test the test arguments but to test the macro functions. So it is ok I think 👍. Common Naming's Partly it is very hard to choose the right name of each definition to show what the definition stands for regardless if function variables or constants. Upload my Repositorry I used Git of course for my project a3-lib-checks. when I started to upload there was an error occurred. Something with ssh I need to use and not TSL as the standard. So I Website Entrypoint I set the entrypoint of GitHub webpage. Nothing happes. I'm on to get thing done! Bugs As I said, the project is a BETA VERSION so there could bugs occurs, regardless of units tests! I’m just one person in the Project! Please email me or contact me in this thread or write a PN to me in this platform if there is any bug displayed with my macros if you include correctly of course 😉. Feedback Feedback is very welcome 🙂. It is useful for me to get feedback on my macros and my project. You can Criticism me, regardless if positive or negative. Every feedback is useful if the feedback is objective. Apologizes English is not my mother tongue. I hope, it can be understandable if someone reads my scrip comments I am just a Developer with amateur experience on Arma coding. I'm a greenhorn in https://github.com/. It is completely new to me. So I hope everything is clear by now 😬🙄 . Enjoy Coding 😊 Best regards MB Edited September 15, 2021 by bi_mg two text contents added under "My Problems"; crossed through one content & add Links; 1 Share this post Link to post Share on other sites