|
Member 3981366 wrote: Pls reply ASAP.
This is more likely to stop people from replying. Everybody here is a volunteer, if your problem is that urgent, then get your credit card out and go to rentacoder.com.
Firstly, try not to use ArrayList , use List<T> instead. It is type safe and more efficient. Look it up in the documentation for further details.
Something like:
List<DateTime> timeList = new List<DateTime>();
DateTime startTime = new DateTime(1, 1, 1, 9, 0, 0);
DateTime endTime = new DateTime(1, 1, 1, 18, 0, 0);
while (startTime <= endTime)
{
timeList.Add(startTime);
startTime.AddMinutes(15);
}
would work.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
To me, "ASAP" means the same as "when you can get around to it".
|
|
|
|
|
What will you do with it?
Depending on what you plan to do, you may not actually need to store all that in memory.
Here's an enumerator from my TimeRanger[^] article:
public static System.Collections.Generic.IEnumerable<System.DateTime>
MinuteEnumerator
(
System.DateTime StartPoint
,
System.DateTime EndPoint
,
ushort SteppingFactor
)
{
System.DateTime current = PIEBALD.Lib.LibTim.DateTruncate
(
StartPoint
,
PIEBALD.Lib.LibTim.TimeGranularity.Minute
) ;
if ( StartPoint <= EndPoint )
{
if ( current < StartPoint )
{
current = current.AddMinutes ( 1 ) ;
}
while ( current <= EndPoint )
{
yield return ( current ) ;
current = current.AddMinutes ( SteppingFactor ) ;
}
}
else
{
while ( current >= EndPoint )
{
yield return ( current ) ;
current = current.AddMinutes ( SteppingFactor*-1 ) ;
}
}
yield break ;
}
Or you could use this to load a List if you really want to store the information.
|
|
|
|
|
how to use ascii code??
i want when i press enter key my button is click.
how i do this???
|
|
|
|
|
Firstly, read the bit at the top of this list, where is says "How to get an answer to your question".
"Hi.." is not a description of your problem. A description that relates to the problem encourages people who think "I might know the answer to that" to look, and maybe, to answer...
Secondly, I know English is not your first language, so I am guessing that what you want is:
You have a form of some kind (lets call it Form1), which has a button (lets call it Button1).
When you press the Enter key, you want the buttons click event to be fired.
If so, then: Click on Form1 in the design view, and look at the properties.
Find the "Accept Button" property.
Use the drop down list to select "Button1"
Build your project.
Enter will now activate the Button1 Click event.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Jeepers. Have you thought about buying a book ? Have you read my article on how to use google ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If I can't use Google, how am I supposed to find your article...?
|
|
|
|
|
If they have the ability to use a forum to post these messages, they shouldn't have any problems using Google.
|
|
|
|
|
Hi there,
I have a StreamEvent from a StockExchange Data Provider API. The Event is triggered every time a new price occurs for the respective Instrument on the Exchange.
I can fill the Stream with multiple Intruments, lets say 50.000. So the StreamEvent is triggered about mutiple thousand times in one second.
In the Stream, I first check the price difference in percent between the last price and the new one:
private double abw;
void TPBrief_Brief(int SymbolNr, float NewPrice, float Volume, DateTime Time)
{
abw = (((InstrumentObject)os[SymbolNr]).LastPrice - NewPrice) / (((InstrumentObject)os[SymbolNr]).LastPrice/ 100);
if (abw >= 1.5) {
}
As you can see, I hold my Instrument Objects in a Hashtable, key is Symbolnr, value the InstrumentObject. The first line in this event is the one which is triggered that often, so I just want to know how to optimize this line.
As I learned from various articles, Hashtable should be replaced with a Dictionary, this is one thing I will do.
But what about this variation:
void TPBrief_Brief(int SymbolNr, float NewPrice, float Volume, DateTime Time)
{
IntrumentObject io = ((InstrumentObject)os[SymbolNr]);
abw = (io.LastPrice - NewPrice) / (io.LastPrice/ 100);
if (abw >= 1.5) {
}
Could this be faster than the first one? What's about the Calculation of the difference? Can this code fragment be optimized?
Any help would be appreciated!
|
|
|
|
|
As far as calculating the difference is concerned, may I suggest that you google, bing or otherwise search on performance measurement c#, as there are so many hits that it is difficult to recommend just one.
As far as optimizing the code, the only real way to tell is to measure the performance of as many variations as you can think of. I am not able to see anything obvious, although I am pretty sure that others will offer an opinion.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I doubt this calculation is a bottleneck. Have you done any performance profiling? How much throughput are you getting at the moment? How much throughput are you getting with this handling code removed?
Anyway, a bit of maths gives:
abw = NewPrice / io.LastPrice;
if ( abw >= 1.015 || abw <= 0.985 ) {
Also, if the SymbolNr values are sequential ( or at least small ), you could use an array of InstrumentObject with SymbolNr as the index.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Thank you for your input. The Calculation of the Percentage is a good one
I tested now the calculation with this different algos:
private void StreamEventHash(int SymbolNr, float NewPrice, float Volume, DateTime Zeit_kurs)
{
abw = (((OSObject)osHash[SymbolNr]).LastPrice - NewPrice) / (((OSObject)osHash[SymbolNr]).LastPrice / 100);
if (abw >= 5)
{
}
}
private void StreamEventHashNewObject(int SymbolNr, float Kurs, float Volume, DateTime Zeit_kurs)
{
OSObject oo = ((OSObject)osHash[SymbolNr]);
abw = (oo.LastPrice - NewPrice) / (oo.LastPrice / 100);
if (abw >= 5)
{
}
}
private void StreamEventHashNewObjectAs(int SymbolNr, float Kurs, float Volume, DateTime Zeit_kurs)
{
OSObject oo = osHash[SymbolNr] as OSObject;
abw = (oo.LastPrice - NewPrice) / (oo.LastPrice / 100);
if (abw >= 5)
{
}
}
I use the stopwatch class for this. I found out that the first one is the slowest So there is performance optimization possible.
But I can't tell which one of the other 2 algos are faster, because when I change the order the voids are tested, different results occur. It seems that the one which is tested first is always a little bit slower. I am about to figure out how to get reliable results, maybe to run the tests multiple times in random order.
And than I have to find out what your proposed algo
abw = NewPrice / io.LastPrice;
if ( abw >= 1.015 || abw <= 0.985 ) {
will do
modified on Saturday, July 11, 2009 8:31 AM
|
|
|
|
|
I'd try multiplying by 1/100 instead of dividing by 100, the optimizer is not exactly smart but it will always collapse constants such as "1/100" - and seeing as an fdiv is like 15 times (depends on the divisor) as slow as an fmul and not even pipelined, the difference could be huge.
|
|
|
|
|
Thank you very much for your input.
Anyway, I found out that 1,000,000 triggers only take appr. 500 ms. So this can't be my bottleneck
modified on Saturday, July 11, 2009 10:30 AM
|
|
|
|
|
Oh, I don't know that
That's not exactly useful for you to know, but if I hadn't said it you might be waiting for my reply..
I hope someone else here knows more about that kind of thing
|
|
|
|
|
I found out that 1,000,000 triggers only take appr. 500 ms. So this can't be my bottleneck Frown
It seems that the bottleneck is on the DataProvider APIs side. If I put more than 50.000 instruments in the datastream, then somehow sometimes the events aren't triggered anymore. This is my main problem.
BUT: I now that this has somehow also to do with CPU power. This 'disconnects' happen much more often on systems with slower CPU's. So I think there should be a possibility to improve my App - but I don't know where. I already tried to raise the priority of the DataProvider Client Process - no result.
It seemes that somewhere in the system, if the traffic is high enough, there is a traffic jam causing the strange behaviour. Should I change something in the Network Preferences? But what?
|
|
|
|
|
this is my code
i want the start menu to pop up thru like we press the start button
private void page_Load
{
if(condition)
{
//invoke the start key. i want the menu to pop up just as we click the start menu
SendKeys.Send("^{ESC}");
}
}
its not working
This code was posted by me...
|
|
|
|
|
This will not work, since you send this key strokes to your application only, and not on global level.
Have a look at here[^], it is in VB, but i'm sure you will manage to make in in C# in matter of seconds.
|
|
|
|
|
i need code in c# please send a link containing C# code
This code was posted by me...
|
|
|
|
|
how do i import user32.dll in c# in this contest
This code was posted by me...
|
|
|
|
|
Hi
I have problem in picturebox.
i want to load picture run time basis how can i do this???
|
|
|
|
|
|
thanks sir.
now i want to show that pic the value of textbox.text
for example
my pic location is file///e:/pic/1.jpg and user type in textbox "1" then show pic 1.jpg and user type "2" show pic 2.jpg.
how i do this???
|
|
|
|
|
mjawadkhatri wrote: how i do this???
By getting a beginners book on C#, reading through it carefully and attempting all of the examples.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Means u can't help me in this??
|
|
|
|