|
I just had a look and think they actually probably want to use enter. Hover is if it goes over, enter when they use the control
|
|
|
|
|
maybe just like this
private void textBox1_Enter(object sender, EventArgs e)
{
textBox1.Text = String.Empty;
}
welcome to www.ideaext.com
|
|
|
|
|
Hi all,
I had an application on vs2003 in c#.net.
the execution/processing speed is kind of slow.
Suppose there are methods as
dtStart = Now;//date time obj
MethodA();
.
.
MethodG();
dtEnd = Now;//date time obj
I use datetime class to find out the elapsed time as
elapsed = dtEnd - dtStart;
elapsed time is approx 2.81 sec. or always above 2.5 secs.
Is this is slow?
What these methods are doing is operating upon some string,bool,array datatypes.
mostly string manipulation.
One Big string and then extracting other string obj from this !!
but most string,bool, etc data types are local to methods, and i guess they got out of scope(eligible for garbage collection) after method lost focus.
a)How can i speed up execution?
b)Is there a way to find out which method is taking most time or culprit method/object/operation?
regards
|
|
|
|
|
Hum Dum wrote: a)How can i speed up execution?
Rewrite your code to be more efficient
Hum Dum wrote: b)Is there a way to find out which method is taking most time or culprit method/object/operation?
Yes, several methods including profiling.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Ashfield wrote: Bob
Ashfield Consultants Ltd
your reply is really like Consultants !!
so near but yet so far
I know i have to rewrite that's why i asked?
|
|
|
|
|
Well, without seeing the code how can anyone advise you on whats wrong? I can make several guesses, but its pointless.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hum Dum wrote: a)How can i speed up execution?
Start with b, so that you know which part of the code that needs optimising.
Hum Dum wrote: b)Is there a way to find out which method is taking most time or culprit method/object/operation?
The most basic would be to get the execution time for each method to see where the most time is used. You can use the StopWatch class to get better resolution than DateTime.Now offers.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
thanks for your reply.
Guffa wrote: The most basic would be to get the execution time for each method to see where the most time is used
There i am calling approx. 12-15 methods call in total, embedded inside one method,
so, for each method "Do i have to do this?"
Or is there any vs tool which helps me in finding out time taken by methods?
|
|
|
|
|
|
Hum Dum wrote: Is this is slow?
[...]
mostly string manipulation.
Research the StringBuilder and read up on Regular Expressions
I are troll
|
|
|
|
|
Eddy Vluggen wrote: Research the StringBuilder and read up on Regular Expressions Smile
I already done that, It says this is only useful if you are performing operation on single string like appending, manipulating the same one.
But here, what i am doing is extracting many small string from ONE main string, also passing this Main string to different method. and on these small strings i don't perform any operation and yes i am using regular expression for extracting peculiar strings
Any other help/comment on my this way would be appreciated.
Or any other light
regards
|
|
|
|
|
insert Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff")+": some text"); at several locations in your code, that will immediately tell you where most time is spent.
Regexes are anywhere from very slow to slow; optimize them, and/or throw them out and write proper search and replace code yourself.
Whatever you do, don't show us your code; someone might spot the problem at once.
|
|
|
|
|
Luc Pattyn wrote: Whatever you do, don't show us your code; someone might spot the problem at once.
Aah !! that i will never do
Well after putting up several DateTime.Now i found the real culprit, and to utter most surprise its not string function which i had wrote .
Its turns out to be display notification(as in Messengers there comes a pop up window at bottom right corner, not written by me ). Its consuming 2.5 sec out of 2.7 sec.
So, if you plz help me with this!!
Can we show this notification parallel, and move on to later execution.
not waiting until it ends up !!
How should i do this, any help/link would be appreciated.
But still curious, Is this approx .2 sec(subtracting time taken by notification) also slow??
your opinion?
regards.
modified on Tuesday, April 28, 2009 3:33 AM
|
|
|
|
|
Hum Dum wrote: pop up window ... consuming 2.5 sec
Then find or create a better popup. I trust it is not consuming 2.5 sec, instead the animation lasts that long, and nothing else happens in between because it isn't based on a timer nor a thread (so just a bunch of Thread.Sleep calls).
Hum Dum wrote: Is this approx .2 sec also slow??
Throw out the slow animation, look at the timestamps, and decide for yourself.
|
|
|
|
|
|
Hi,
I could write a book on software performance, it is a huge topic.
You haven't told hardly anything about your app, and haven't shown any code, so how could anyone judge its performance?
From experience, in 0.2 sec one can do any of the following:
- copy 100MB of data (RAM to RAM)
- read 10MB of disk data
- calculate 10 million prime numbers
does your program come close to any of those? if not, you probably are wasting time/cycles/...
guidelines:
- make it work correctly first (without using silly algorithms, silly coding); then optimize
- choose your algorithms carefully
- choose your data structures carefully
- don't use polling
- measure the results accurately
- consider and compare alternatives
- consider caching
- ... the list goes on
- as always, there occasionally may be a valid reason for not obeying some of the guidelines
Hum Dum wrote: so that no one can post my code here on coding horror forum
that is a dumb reason.
if there were a "stupid questions" forum, would you stop asking questions?
|
|
|
|
|
thanks for valuable time and guidelines, I will keep in mind.
Luc Pattyn wrote: if there were a "stupid questions" forum, would you stop asking questions?
Aah it seems like if there was no stupid then there were no clever ones.
After all both completes each other .
Hope you keep up well n be available here to answer other needy ones!!
regards,
Keep
|
|
|
|
|
hi
in my project i convert excel file in xml and then upload the file in data base . here i use SQL Server 2005. In my excel file consist one record D'Souza when such name comes program throw run time exception as Incorrect syntax near 'Souza
i use following query for insert a record
string istr = "insert into sheet1(Personnel_Area,EE_Grp,Employee_Group,ESgrp,Employee_Subgroup,Cost_ctr,Cos
t_Center,PSubarea,Personnel_Subarea,Peres_no,Personel_Number,Designation,D
esigna,Pos,Age_of_Employee,Birthdate,Complete_name)values('" + Convert.ToString(dataGridView1.Rows[i].Cells[0].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[1].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[2].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[3].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[4].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[5].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[6].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[7].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[8].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[9].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[10].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[11].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[12].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[13].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[14].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[17].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[18].Value.ToString()) + "')";
|
|
|
|
|
hi
in my project i convert excel file in xml and then upload the file in data base .
here i use SQL Server 2005. In my excel file consist one record D'Souza when such
name comes program throw run time exception as Incorrect syntax near 'Souza
i use following query for insert a record
string istr = "insert into sheet1(Personnel_Area,EE_Grp,Employee_Group,
ESgrp,Employee_Subgroup,Cost_ctr,Cos
t_Center,PSubarea,Personnel_Subarea,Peres_no,Personel_Number,
Designation,D
esigna,Pos,Age_of_Employee,Birthdate,Complete_name)values('" +
Convert.ToString(dataGridView1.Rows[i].Cells[0].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[1].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[2].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[3].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[4].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[5].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[6].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[7].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[8].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[9].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[10].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[11].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[12].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[13].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[14].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[17].Value.ToString()) + "','" +
Convert.ToString(dataGridView1.Rows[i].Cells[18].Value.ToString()) + "')";
|
|
|
|
|
What was wrong with this[^]? Please don't re post the questions.
Voted to remove message
|
|
|
|
|
do you have a question? or do you just want us to point out the bad things about what you have done?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
what ever i did it's work but when the word D'Souza comes it throws exception
when i delete the record D'Souza all the records (13,000 record) insert in to the table
so i am not point out my bad things.
i need some help or logic who elemenate such run time error.
|
|
|
|
|
ok, well you should check your other post about SQL Injection because using values directly from your table is causing the problem, the ' character in the name is what the sql query is not liking. What you need to do is use command parameters and insert your values that way.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Read and apply the answer that was given to your first post.
And NEVER use string concatenation to build queries in c#.
Edit: beaten by musefan
Edit2: I just remembered this xkcd comic[^]
modified on Monday, April 27, 2009 9:25 AM
|
|
|
|
|
I know that it is possible to run user-edit code within interpreted langauge such as Matlab, TCL and so on.
user can edit/add their own scripts to these interpreted language based application.
is it possible to do smilar things in c#?
to be clear, I want to do the following:
the user can give the values of array of x, y by programming, then they will be plotted by using one plot function.
sth like (simple example):
the user can edit the following code in a given richtextbox:
for (int i=0;i<100;i++)
{
x[i]=i*2;
y[i]=Math.Sin(x[i]);
}
then the application can know the x and y and then call one function plot_my(x,y).
is it possible to do so?
|
|
|
|
|