Regex Improving Performance With Compiling And Shared Variables
Sep 30, 2011
I am writing some code that uses fixed regexs to search strings and pattern match. Its simple stuff, but I want to improve regex performance with compiling (its a high traffic website). I was thinking of compiling the regex and putting it in a Shared (static) variable inside a class. Something like this:
[Code]...
View 1 Replies
ADVERTISEMENT
Jun 8, 2009
I came across a number of new Private Shared variables (of type Hashtables(Of String), initialized in the declaration) added to a partial class for a very large (DataContext-derived) class. This seems sensible to me in one sense because they never change, and making these shared variables ensures that they won't get re-initialized every time a function is called. However, these variables are only used within the scope of one function in the class, and I fear the private namespace of this DataContext-derived class is getting rather polluted, and having these sorts of things exposed at such a high level might be confusing to others reading the code in the future.
Would there be negative performance impact to making these local variables within the function where they are used, or is there some better way to handle this? Basically we are using these 3 hashtables to determine whether anything within particular subsets of properties changed (using GetModifiedMembers and then using the Overlaps function of the hashset to see if any of the modified members correspond to members we care about).
Edit: I caved and took the time to write my own test program, which confirmed that there is a cost to using local variables (which I assume applies generally to all cases -- I doubt there's any case where a shared variable would be slower unless using the shared variable requires some additional logic to do so properly): [Code]
So in this particular case, using the local variable costs about 200%. But in most cases (including my own), the time is probably negligible compared to the overall task. So I guess the question now becomes, how do people generally feel about improving code maintainability at the cost of negligible but known performance impacts?
View 3 Replies
May 22, 2010
I am dealing with a situation that I need some help with here. I need to improve performance on functionality that records and updates UI with user selection info. What my code current does is
'This is called to update the Database each time the user 'makes a new selection on the UI
Private Sub OnFilterChanged(String newReviewValueToAdd)
AddRecentViewToDB(newReviewValueToAdd)
UpdateRecentViewsUI()
PageReviewGrid.Rebind()'Call Grid Rebind
End Sub
[Code]...
View 2 Replies
Dec 15, 2011
Is there a performance difference between these two compiling options?
View 5 Replies
Sep 12, 2009
I have a program which builds a child program during runtime, it all runs fine but I want I way of determining which computer it came from. It is private and when I give it to someone I get their volume serial number and I can identify who it is from that. Once they build their program which can be public so the same method won't work I want it to know it came from person.. pseudo code ex
BEGIN
Determine Person
Build Program
END
[Code]....
View 1 Replies
Jun 4, 2010
I am trying to add shared members in derived classes and use that values in base classes...
I have base
class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class
[Code]..
currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...
View 2 Replies
Feb 7, 2012
I'm wondering about the performance differences between imports and inherits in a .net app.I currently program by creating multiple classes that logically define my objects. e.g. a class for customers, users and product.When i want to use these classes in a page i have to import them eg. "Imports Custmomers" and then later in my code i have to create a variable and datatype it before i can use the sub routines and functions from class.I understand from a coding perspective this keeps it all neat and tidy.So my question Would it be not better to combine all my classes into a base class, inherit that base class, rather than import it, when i want to use it and so cut down on the extra declarations and associated code that come from importing a class; and if i did this would it aid performance?
View 1 Replies
Jan 18, 2011
I have a problem with inherited classes. Have a look at the following VB.NET 2.0 / VS 2005 code:
MustInherit Class templateclass
Public Shared x As String
End Class
Class child1
[code]....
The templateclass has a shared variable x which is of course inherited by the child classes. But I wonder that all child classes share only one x! Until now I thought that shared variables are only shared among the instances of a class, not among all childs. This is very annoying because I have a base class which I need in two slightly different versions and they should not "share the shared" variables. And because the classes have a lot of shared variables, shadowing each in the childs would be very..
View 1 Replies
Oct 20, 2011
I'm trying to split some prior crafted code into a DLL. It's a simple logger system.There are a few things that need to be shared with the main form in the project, so I set them up as a shared variable, but I don't use shared stuff often, and I worry it will cause variable conflicts regarding scope. I figured I would make a post here about it and see if someone can explain what I don't fully understand.Since this is a logger it will be used a couple of places. Other DLLs that need logging may reference it through a instanced object and project reference. My main form will also have an instanced object and a reference to the logger libary.Since one of my properties is a connection string and it's shared, does this mean that a instance of my logger class inside a DLL will have the same shared values as a instance on my main UI form? Or will the fact that the instance is inside of a DLL provide the scope boundary I need?
View 1 Replies
Mar 13, 2012
I was reviewing the MSDN documentation on VB.Net's little-used Static keyword for local variables. My question is not about how Static works (I personally plan to avoid using it as it seems like it could cause grief to future programmers who don't notice the side-effects.) My question is about this statement in the docs:[code]So can anyone interpret the above statement for me in a way that makes sense? Or is this a bug in the documentation? It's been there since the VS 2005 version of the docs and is still present in the Visual Studio 11 version.
View 2 Replies
Jul 23, 2009
I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.
View 8 Replies
Jun 22, 2009
exact diff b/t Static v/s Shared variables in VB.NET?
View 3 Replies
Nov 29, 2009
basically i was wondering if we could inherit shared variables but restrict its scope to only that of the class itself.
Class A
Public Shared shared_variable as Boolean = true
End Class
[code]....
when i do this A.shared_variable = False, B's shared_variable also becomes false. how do i stop this?i cannot remove the Shared keyword because shared_variable should be able to be accessed without an instance of the class?
View 7 Replies
Feb 21, 2012
I've been doing some reading on garbage collection in .NET and I was hoping for some clarification. So, as I understand it if I declare a public shared class variable, the GC will never get rid of it. Is this correct?Also, what then of private variables? Take the following example:
public class myClass
private shared myString As String
public sub ChangeString(newString As String)
[code].....
View 4 Replies
Mar 12, 2012
So I am currently attempting to wrap my head around create multi-threaded programs and I am currently running into an issue when using a Shared variable across multiple threads.The program is structured as follows: Public Shared IsActive as Boolean
Main Thread = GUISets the Value of IsActive through a Button ControlTwo Worker ThreadsBoth threads are while loops that read the IsActive Boolean Ex:While IsActive = True Do Work End WhileHowever when I change the value of IsActive from the Main Thread it causes the worker threads to stop (ThreadState = 16).
I have been reading that I have to synchronize/lock shared resources and have tried SyncLock and Monitor methods without success (it is entirely possible I am not using the above correctly, so If someone could provide proper examples for the above situation using the mentioned methods please share them).
View 4 Replies
Feb 15, 2009
I have created a public shared subroutine in a class file in asp.net 2 (vb.net) web site app_folder.The subroutine retrives some values from a sql database via an sql query and assigns the datareader field values to several variables The problem is I can't seem to assign the variables from the subroutine to the variables and textbox controls in the asp.net page I am calling the subroutine from. The textbox text value just appear blank.By the way, if I response.write the variables in the subroutine they appear populated by the sql data reader.
View 9 Replies
Jul 31, 2010
Are the following three the same upon compilation
dim x as new assigningfunction
dim x as new assigningfunction()
dim x as assigningfunction = new assigningfunction()
[code].....
View 4 Replies
Apr 23, 2012
Public Shared _formRef As frmMain
Public Shared f As frmMain
Class Server[code].....
but once firing off the code i get the error you see in my image attached.
View 1 Replies
May 19, 2011
Well I am a new to VB.NET, converting a legacy system to .NET world. Recently I have been reviewing the already existing code since I joined the project quite late in the team. I find that there are many shared functions (not shared class) inside many classes. I doubt this may create some problem if two requests ( i.e two different HTTP request to the same method as it's a WCF application, of course exposed methods are not shared but internally called methods are shared) comes to the same shared method and both the calls to the method may have different method parameters/arguments, overwriting each other's arguments. In short, if shared method has a list of arguments which is going to be processed, is there any chance of inconsistencies in the light of multiple access to the shared method via two http requests.
View 2 Replies
Jul 22, 2009
give me a good resource that explains the difference between a Private, Public, Shared Functions/Sub/Variables? I normally use Public for Subs/Functions inside of Modules I call from other parts of the program. But I'd like to get more of an understanding of how and when to use them. I want as little as impact to a system that is running my programs as possible, so i guess the key here is I'm trying to just get more proficient in my coding.
View 8 Replies
Dec 8, 2011
I have the following class which I want to serialize to XML:
[Code]...
View 3 Replies
Aug 23, 2011
Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?
[Code]...
View 3 Replies
Dec 28, 2009
I've found out that if two instances of an SSRS report run at the same time, any Code variables declared at the class level (not inside a function) can collide. I suspect this may be the cause of our report failures and I'm working up a potential fix.The reason we're using the Code portion of SSRS at all is for things like custom group and page header calculation. The code is called from expressions in TextBoxes and returns what the current label should be. The code needs to maintain state to remember what the last header value was in order return it when unknown or to store the new header value for reuse
View 11 Replies
Feb 15, 2010
In one of my forms witch I imported from VB2008 there are all properties saved in the *.resx file. One Property, of the Type System.Windows.Forms.Keys, can contain the Value 'Ctrl+F1' witch compiles fine in VB2008, but not in VB2010. To reproduce, simply add the following to any resx file:
<data name="cmdFenster.ShortcutKeys" type="System.Windows.Forms.Keys, System.Windows.Forms">
<value>Ctrl+F1</value>
</data>
It will compile fine with VB2008, but not with VB2010. Notice: The VB2010 also generates this Code in the resx file
View 2 Replies
Dec 10, 2009
I have an idea about improving the assigning operations of VB.NET (maybe other .NET languages too.) It is similar with "With ... End With" block:
[Code]...
So we don't type "Some Text" every time. Do you think does this idea work? Maybe in the future we can see something like that?
View 3 Replies
Mar 19, 2011
In our database we have gigantic tables (it was initially built 20 years ago). We are on the process of developing it.
Some tables contain rowversion and optimistic concurrency. We were wondering if there is a way to just correspond rowversion to the modification of some specific columns, but not all of them. In Normal Case, T-SQL which is generated then would be huge.
View 1 Replies
Apr 13, 2012
A few years ago we (as a company) faced the scenario of getting our developers to stop writing classic asp pages and switch to .net (and in turn system.data for data access). As a supposedly ˜short term measure I wrote the following class to make the switchover easier for those not used to system.data & all its new objects: [URL] The main purpose of this class was to keep usage as similar to classic asp as possible & keep the usage VERY simple (plus to add email alerts for error catching yada yada yada):
[Code]...
View 2 Replies
Feb 17, 2012
I am looking for recommendations with regards to any tips and suggestions on the improvement of the look and feel of windows forms designed in vb.net studio.I was used Krypton but my trial ran out and I am looking for other packages, tools or ways to improve the look of my forms.
View 5 Replies
May 22, 2009
I am putting some heavy though into re-writing the data access layer in my software(If you could even call it that). This was really my first project that uses, and things were done in an improper manner. In my project all of the data that is being pulled is being stored in an arraylist. some of the data is converted from the arraylist into an typed object, before being put backinto an arraylist.Also, there is no central set of queries in the application.This means that some queries are copy and pasted, which I want to eliminate as well.This application has some custom objects that are very standard to the application, and some queries that are very standard to those objects.
View 5 Replies
Jun 21, 2009
vb.net
'strSearch = textBox.Text, columns 2 to 10 are the optional columns you want to search to. Function WhereQuery(ByVal strSearch As String, ByVal column1 As String, Optional ByVal column2 As String = "", Optional ByVal column3 As String = "", Optional ByVal column4 As String = "", Optional ByVal column5 As String = "", Optional ByVal column6 As String = "", Optional ByVal column7 As String = "",[code]..
sample output:
im also thinking on using stringbuilder to replace my strings.
View 1 Replies