Quick way to add Stopwatch.start and Stopwatch.end to all functions vb.net - vb.net

Just trying to look at a quick way to find the timings for each individual function in my application. Would like to optimize code and see if some function is taking longer than others but was wondering if there was some quick way i could add the Stopwatch.start and Stopwatch.end to the beginning and ending of each function. Could someone assist me in what to google? I can see how I want it to work but have no clue on how to start.
Not looking for answers, just guidance :)
Thanks!

You can use ReSharper (or something similar) to create a macro for your functions that would include the stopwatch code.

You could use a select-case block in your class. Use an enum to call the functions by name. The select block can then run the correct function according to the enum value. It'll be rather long but you only need the stopwatch calls around the select block and they will get called for each function.

Related

How do I implement a PDDL generated plan into a Python code communicating with motors?

So i have a problem which I modeled using PDDL. I want to implement the plan generated from this problem to a an existing Python code which controls two motors via Wi-Fi with a loop on VS Code (Python). I want this code to take my plan and execute it. Does this mean I need to define the actions I have as functions for my Python code and read the .plan file as a text and call the functions step by step? What are other options I might have?
Thank you for sparing your time!
Yes, it means that for every action of your PDDL, you have a corresponding function. And for every object in your problem, you have a corresponding instance that you can pass as an argument to the functions.
When you get a plan, you must parse it, take the step of the plan and:
look up the function by your action name
look up the instances by name to pass them to the function.
Once the function completes successfully, repeat.
Note that if you want to be able to interrupt the action while it is ongoing, you might need more complex kind of functions, if not objects.

What's the AHK equivalent of one-line logical OR short-circuit evaluation?

For example, in JavaScript, the following code would log foo:
false || console.log('foo')
How to achieve the same logic in one line in AutoHotkey?
The same is possible in ahk.
I'm guessing a problem you might be facing is if you tried to use normal commands with it. It's not possible you'd have to be calling functions.
If the thing you want to call is a command you might need to make a custom function to wrap it and be able to use it as function.
(Ahk v2 would be more comfortable to use in this regard but it's still in beta.)

WinDev - Using a variable in a Looper Content Query

I am hoping someone will be able to point me in the right direction. I have a Looper control within WinDev and am filling the Content using a Query.
How do I utilise a global variable within the query? It seems that it must be passed in as a parameter to the query, however there is no opportunity to set the parameter unless executing the query from code. It all seems a little contradictory and I am sure I'm missing something obvious.
UPDATE
Having read about MySource but also read that MySource cannot be utilised in an Initialization block; I have moved the query to independent. Thereby allowing me to set the parameter with
Query name.Parameter = Value
However, although the Query is specified in the Content table of the Looper control, it does not seem to return anything.
Have tried calling HExecuteQuery() and LooperDisplay(), neither of which seem to do anything.
The query is a simple select and works when tested in the query editor.
Any help would be greatly appreciated,
It turns out that I had to go into the Description of each field and re-click the Link entry. Nothing changed as I clicked them but the data now appears.
Not a great solution but it resolved the issue :-(
Changing from embedded to independent is the best thing you could do and it's the best practice as well. Once the source has changed though you do have to rebind all the data to the attributes since it loses it's references.
You better execute the query at the window's Global Declarations section if you don't want to eat up resources and I/Os for nothing by using the Window's End of Initialization section like I've seen people doing .
This way you don't need to call LooperDisplay() and your independent Query will only be called once by your HExecuteQuery().

Build if then statements at run time?

My product owner has asked me to make some comparision logic configurable so the process engineers can change things without making code changes. Currently the code is a SELECT CASE statement with various IF THEN statements that are fairly standard. The problem I can't seem to find a way around is that he wants through configuration to AND/OR a variable number of comparisons in the IF THEN statements. His idea is the that the configuration would work like a limited query builder for the process engineers. The only solution I've come up with is to build a function in a string and use the VBCodeProvider to compile it at runtime. Is there a better way to approach this?
One way to do it is just store the booleans in your configuration file, load them up at run time, and use them in your code like any other boolean.
A better way would be to have the configuration as close to his problem domain as possible, then code up the proper booleans from those to use in your code.
You could use expressions to accomplish this. With this you would be able to build up an IfExpression and build up its conditions. You would be able to compile this and run it all at runtime.

Visual Studio - automatically add necessary spaces to comments

When I'm writing comments in my code, I often forget to add the initial space after the comment identifier.
'this is a comment
when really it is supposed to be
' this is a comment
I realize this is quite trivial, and you could simply say "just add the damn space you idiot", but I'd really like to automate this so that I just don't have to worry about it.
Can anyone point me in the right direction of an elegant way to add the comment space?
note I do realize that a catch all string replace or regex replace could screw up other things ... IE:
Dim something As String = "I'm a nerd"
would actually come out
Dim something As String = "I' m a nerd"
So the way I see this being resolved is if it's only on a line by it's self and is not followed by a second single quote... IE: '' would not trigger the replacement.
You could always get a copy of resharper and one of the rules in there is what you are describing. Once you finish with your code you can do a format on the whole file or even solution and it will globally fix that rule for you.
This would be a pretty good case for an editor extension. You can detect when a line is whitespace, apostrophe, not white space and either insert the space or put a decoration so you will learn to follow the pattern. If you've moved to 2010, consider it - they are really pretty easy to write.
I had and have similiar problems. This is a habit which you can change. Yet, sometimes your brain is just wired to make the same mistakes. For instance, no matter what I do, I always type data instead of date.
You can change your behavior. Find some method that you find helpful for changing habits. Create a "personal code review" checklist and add this item. After a few months, you will find the space comes naturally.
If this is one of the "hard-wired" brain goofs, then create a *Visual Studio" macro that visit's CodeDom. Through the CodeDom namespace it is easy to find comments and make changes as needed. Why use regular-expressions?
If you want to use regular-expressions, because you are familiar and it is easier, then create a better expression to avoid potential errors.
Refactoring VB.NET code with regular expressions at http://www.vbmigration.com/Blog/post/2008/07/Refactoring-VB%2cNET-code-with-regular-expressions.aspx should be helpful in creating better regular-expressions.