473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

any preformance tips ?

Hi,
I have several gigabytes of CSV files - coma seperated variables (in text)
I find the converting to numbers is a bit slow,
to double or int seems about the same,
using split seems to take longer than substring,
seems no alternative to parse/tryparse.
although I havnt tested to see wich is faster.

It reads the file at a rate of about 1 million lines a sec wich is probably
as fast as the system will allow,
but only about converts 100k lines a sec with 5 numbers in each line,
this seems rather slow, must be many thousands of instructions per
conversion,
im running on a 64bit amd ~ 2ghz, 3gb ram.

I do this in assembler in my PIC mcu in a lot less lol.

the number crunching wich is quite involved can also do about 100k lines a
sec,

I have seperate threads for each step so I can delay the start of the next
thread to see how fast it is.
otherwise its procesed and displayed as it comes in.

I could do with speeding up the number crunching too,
I found it considerably faster to use structs instead of class
to organize the data, wich is a couple of complex numbers per point, plus
DateTime.
the data is stored in chunks in List<>

but theres lots of function calls as its quite structred with a complex
class I copied from somwhere
howcome c# doesnt have its own complex class or even a complex variable type
?
do simple functions get inlined ? or is this not happening in debug.
I read the Jit makes its own mind up about inlining,
structures get passed by value on the stack though
I tried using ref but got into trouble as then you cant pass values from
function calls directly.

I also run into memory problems, I need to keep all the data I read in as it
takes long to convert it,
then do statistical noise reduction and more than one FFT
and be able to change parameters and see the results quickly.

I store the files in 1hour chunks wich is about 150k records,
I found it slightly better to use an array[] then resize the aray when it is
finished,
changing the initial size of the array and the increment if its too small
considerably affects the max memory it uses.
I managed to get the memory down to about 115% of the size of data I have.

although I only have a few days data atm,
with a years worth im going to run into problems I think.
its probably going to be more than 4gb,

maybe I should store the input data as binary numbers, or is there a way to
speed this up ?
I would need to store both.

maybe I just though of an idea .. to have a binary cache.
could I simply map the file into memory and make it an array of structs ?
Ive done something like this before with c++
I gues it would need to be unsafe code,
is there much scope for speeding things up with unsafe code?

Im also wondering if its worth going for a 64bit version of winxp,
has any one been down this route with c# and know if its that much better
or has any disadvantages ? I know some things arnt compatable.

thanks
Colin =^.^=
Apr 6 '07 #1
3 1121
Colin,

If you can do this in assembler, then create that code, compile it into
a DLL which exports a function, and then call that function through the
P/Invoke layer in .NET. That would be the best solution. Why rewrite code
when you already have a solution you can just plug into?

Also, you asked why C# doesn't have a complex class or complex variable
type. What exactly do you mean by that? A class definition can be as
simple or as complex as one needs it to be, or are you thinking of something
else.

It seems like you have the solutions already in other code bases which
satisfy your needs. I would find a way to interact with those code bases,
instead of trying to re-engineer the wheel, which is what you are trying to
do here.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"colin" <co*********@ntworld.NOSPAM.comwrote in message
news:Jn***************@newsfe5-win.ntli.net...
Hi,
I have several gigabytes of CSV files - coma seperated variables (in text)
I find the converting to numbers is a bit slow,
to double or int seems about the same,
using split seems to take longer than substring,
seems no alternative to parse/tryparse.
although I havnt tested to see wich is faster.

It reads the file at a rate of about 1 million lines a sec wich is
probably as fast as the system will allow,
but only about converts 100k lines a sec with 5 numbers in each line,
this seems rather slow, must be many thousands of instructions per
conversion,
im running on a 64bit amd ~ 2ghz, 3gb ram.

I do this in assembler in my PIC mcu in a lot less lol.

the number crunching wich is quite involved can also do about 100k lines a
sec,

I have seperate threads for each step so I can delay the start of the next
thread to see how fast it is.
otherwise its procesed and displayed as it comes in.

I could do with speeding up the number crunching too,
I found it considerably faster to use structs instead of class
to organize the data, wich is a couple of complex numbers per point, plus
DateTime.
the data is stored in chunks in List<>

but theres lots of function calls as its quite structred with a complex
class I copied from somwhere
howcome c# doesnt have its own complex class or even a complex variable
type ?
do simple functions get inlined ? or is this not happening in debug.
I read the Jit makes its own mind up about inlining,
structures get passed by value on the stack though
I tried using ref but got into trouble as then you cant pass values from
function calls directly.

I also run into memory problems, I need to keep all the data I read in as
it takes long to convert it,
then do statistical noise reduction and more than one FFT
and be able to change parameters and see the results quickly.

I store the files in 1hour chunks wich is about 150k records,
I found it slightly better to use an array[] then resize the aray when it
is finished,
changing the initial size of the array and the increment if its too small
considerably affects the max memory it uses.
I managed to get the memory down to about 115% of the size of data I have.

although I only have a few days data atm,
with a years worth im going to run into problems I think.
its probably going to be more than 4gb,

maybe I should store the input data as binary numbers, or is there a way
to speed this up ?
I would need to store both.

maybe I just though of an idea .. to have a binary cache.
could I simply map the file into memory and make it an array of structs ?
Ive done something like this before with c++
I gues it would need to be unsafe code,
is there much scope for speeding things up with unsafe code?

Im also wondering if its worth going for a 64bit version of winxp,
has any one been down this route with c# and know if its that much better
or has any disadvantages ? I know some things arnt compatable.

thanks
Colin =^.^=

Apr 6 '07 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:eE**************@TK2MSFTNGP03.phx.gbl...
Colin,

If you can do this in assembler, then create that code, compile it into
a DLL which exports a function, and then call that function through the
P/Invoke layer in .NET. That would be the best solution. Why rewrite
code when you already have a solution you can just plug into?

Also, you asked why C# doesn't have a complex class or complex variable
type. What exactly do you mean by that? A class definition can be as
simple or as complex as one needs it to be, or are you thinking of
something else.

It seems like you have the solutions already in other code bases which
satisfy your needs. I would find a way to interact with those code bases,
instead of trying to re-engineer the wheel, which is what you are trying
to do here.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
erm the assembler code is in fact for a different machine -
a small PIC microcontroller.

the PIC generates the data and sends it to the PC,
the PC does the heavy number crunching and display.

kinda does makes my head spin switching between assembler and c# lol,

Oh wait confusion here, by complex I mean a number type consisting of a real
and imaginary part.

Im trying to get my head round how to transfer an array of structs to and
from a file,
ive got it to write to the file ok using
UnsafeAddrOfPinnedArrayElement(), copying it to a byte[] and using the
File.Write()

wich I found on the web but is there any way to bypass the copy to/from the
byte[] array ?

Colin =^.^=
Apr 6 '07 #3
Colin,
If you have the need to do complex math, FFT, etc. take a look at MathNet:
http://mathnet.opensourcedotnet.info/Default.aspx
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"colin" wrote:
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:eE**************@TK2MSFTNGP03.phx.gbl...
Colin,

If you can do this in assembler, then create that code, compile it into
a DLL which exports a function, and then call that function through the
P/Invoke layer in .NET. That would be the best solution. Why rewrite
code when you already have a solution you can just plug into?

Also, you asked why C# doesn't have a complex class or complex variable
type. What exactly do you mean by that? A class definition can be as
simple or as complex as one needs it to be, or are you thinking of
something else.

It seems like you have the solutions already in other code bases which
satisfy your needs. I would find a way to interact with those code bases,
instead of trying to re-engineer the wheel, which is what you are trying
to do here.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

erm the assembler code is in fact for a different machine -
a small PIC microcontroller.

the PIC generates the data and sends it to the PC,
the PC does the heavy number crunching and display.

kinda does makes my head spin switching between assembler and c# lol,

Oh wait confusion here, by complex I mean a number type consisting of a real
and imaginary part.

Im trying to get my head round how to transfer an array of structs to and
from a file,
ive got it to write to the file ok using
UnsafeAddrOfPinnedArrayElement(), copying it to a byte[] and using the
File.Write()

wich I found on the web but is there any way to bypass the copy to/from the
byte[] array ?

Colin =^.^=
Apr 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Chris Mantoulidis | last post by:
There must be some tips to make a program quicker. I guess more than 50% of ppl here will say "avoid the if-s". Yeah I know this makes a program quicker but some times an "if" is inevitable,...
2
by: Allen Browne | last post by:
If you have bookmarked or linked to the Access tips at this site, please ensure you are using the domain name: http://allenbrowne.com/ If your link contains a reference to the server that...
2
by: alan | last post by:
Hi all, I have create a simple function and make a pure C dll. When I use this DLL from my main program, I found I cannot see this function's definition tips (yellow box). It works fine, but no...
7
by: eyh5 | last post by:
Hi, I'm writing some C codes to run simulations. I'm wondering if there is a website that may contain useful information on how to make one's code run more efficiently and in a...
7
by: Cheryl Langdon | last post by:
Does anyone know if there is a way to globally turn off ALL control tips in Access 2003 using VBA code? Thanks. --- CL
1
by: MrNobody | last post by:
You know those little balloon tips that come out of your task bar- like for example when Windows warns you about window supdates being available? I'd like to create some of those from my C# app......
0
by: nondos | last post by:
Hello, I'm currently design my project menus most of it, is a labels and picturebox which moves and change color, i've notice the preformance is not very well i've would like to know if there's...
0
by: Charles | last post by:
3000 rows is not a big quantity. You can load it into VC program memory, a linked list for example, and "asynchronously" load into Oracle. The connection method can be embedded SQL or ODBC. ...
0
by: zzzmail.01 | last post by:
I find some useful tips about C/C++ and want to share with you. Sorry if it bothers you. Tips for better Coding Style:...
20
Nepomuk
by: Nepomuk | last post by:
As Linux and the various flavours of Unix are slowly spreading into the world of personal computers, I thought we could collect a few Tips and Tricks here to help each other making the best out of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.