Hello!
Maybe someone is able to give me a little hint on this:
I've written a vb.net app which is mainly an interpreter for specialized
CAD/CAM files.
These files mainly contain simple movement and drawing instructions like
"move to's" and "change color's" optionally followed by one or more numeric
(int or float) arguments. My problem is that the parsing algorithm I've
currently implemented is extremely slow.
Basically I'm aproaching these files as follows:
Read 2 bytes from disk and check if these bytes match any known command.
This is done in a large Select Case-statement (about 30 "cases").
If this statement finds a "move to" command, for example, then I'm trying to
extract the arguments.
Please see the following code extract:
Do While ((IsNumeric(str ThisChar)) Or (strThisChar = ",") Or _
(strThisChar =".") Or (strThisChar = "-") Or (strThisChar = " "))
If ((IsNumeric(str ThisChar)) Or (strThisChar = ".") Or _
(strThisChar = "-")) Then
' this character belongs to the current argument
If ((Len(aryValues (lValueIdx)) = 0) And (strThisChar = ".")) Then
aryValues(lValu eIdx) = "0"
strThisChar = "," ' Workaround: this value will become float
End If
aryValues(lValu eIdx) += strThisChar ' Here I'm simply concentrating the
values
strThisChar = m_HPGLFile.Read Char ' this is my input filestream
Else ' finished one argument
lValueIdx += 1
ReDim Preserve aryValues(lValu eIdx)
strThisChar = m_HPGLFile.Read Char
End If
Loop
As you can see, I'm building an array with all arguments that are following
the command.
How would you code such a file parsing algorithm? I strongly believe that my
extensive Select Case-statement and the "argument reader" shown above are my
main bottlenecks. These functions are called thousands of times during file
parsing...
Any hints would be greatly appreciated ;-)
Greetings,
Christoph Bisping 1 2462
Christoph,
One thing I would suggest is that you do *not* read bytes, parse them,
read bytes, parse them, etc.
It would probably speed up your code tremendously to read the entire
file into memory (a collection or array of bytes or something else),
*then* close the file and parse the data you've already read into
memory. All those file access might be costing you a lot of performance,
and you really shouldn't leave files open for any longer than absolutely
necessary.
Christoph Bisping wrote: Hello!
Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement and drawing instructions like "move to's" and "change color's" optionally followed by one or more numeric (int or float) arguments. My problem is that the parsing algorithm I've currently implemented is extremely slow.
Basically I'm aproaching these files as follows:
Read 2 bytes from disk and check if these bytes match any known command. This is done in a large Select Case-statement (about 30 "cases"). If this statement finds a "move to" command, for example, then I'm trying to extract the arguments. Please see the following code extract:
Do While ((IsNumeric(str ThisChar)) Or (strThisChar = ",") Or _ (strThisChar =".") Or (strThisChar = "-") Or (strThisChar = " "))
If ((IsNumeric(str ThisChar)) Or (strThisChar = ".") Or _ (strThisChar = "-")) Then ' this character belongs to the current argument
If ((Len(aryValues (lValueIdx)) = 0) And (strThisChar = ".")) Then
aryValues(lValu eIdx) = "0"
strThisChar = "," ' Workaround: this value will become float
End If
aryValues(lValu eIdx) += strThisChar ' Here I'm simply concentrating the values
strThisChar = m_HPGLFile.Read Char ' this is my input filestream
Else ' finished one argument
lValueIdx += 1
ReDim Preserve aryValues(lValu eIdx)
strThisChar = m_HPGLFile.Read Char
End If
Loop
As you can see, I'm building an array with all arguments that are following the command. How would you code such a file parsing algorithm? I strongly believe that my extensive Select Case-statement and the "argument reader" shown above are my main bottlenecks. These functions are called thousands of times during file parsing...
Any hints would be greatly appreciated ;-)
Greetings, Christoph Bisping
--
=============== =============== =============== =============== ======
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
=============== =============== =============== =============== ====== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Lasher |
last post by:
Hello,
I have a rather large (100+ MB) FASTA file from which I need to
access records in a random order. The FASTA format is a standard format
for storing molecular biological sequences. Each record contains a
header line for describing the sequence that begins with a '>'
(right-angle bracket) followed by lines that contain the actual
sequence data. Three example FASTA records are below:
>CW127_A01...
|
by: SROSeaner |
last post by:
I have a text file that is the result of using XMLHTTP object to pull back a
page of search results from a search engine.
So I have the entire results page in HTML, and want to break out each hit
result from the text file as a unique item and do what I want with each hit
result.
Is there any suggested algorithms or any other techniques I could be
directed to?
|
by: Cigdem |
last post by:
Hello,
I am trying to parse the XML files that the user selects(XML files are
on anoher OS400 system called "wkdis3"). But i am permenantly getting
that error:
Directory0: \\wkdis3\ROOT\home
Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\
You selected the file named AAA.XML
getXmlAlgorithmDocument(): IOException Not logged in
|
by: Sean Bartholomew |
last post by:
i am trying to parse.....:
ifstream newFans ("/Volumes/iBook
Apps/Users/me/Library/Mail/POP-blaha@blah.blah.com/INBOX.mbox/mbox",
ios::in|ios::binary|ios::ate);
so that i could create a tab delimited text file with the fields
filled out from an online form that is sent to my email address.
i used the find all command in BBEdit and found that "\rFirst Name"
accurately located all instances (and no other) of the 1st field in
each email.
|
by: Stork via DotNetMonster.com |
last post by:
Hi,
Just a little background info,
I am working on a WinForms program that allows users to have an eletronic
version of my catalog, since while they are actually looking at peices they
need to buy they won't also have internet access and be able to go to the
website.
The catalog has a feature to be able to 'save quote' which saves the cart
| |
by: Jean-Marie Vaneskahian |
last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net?
I am in need of a .Net class that will allow for the parsing of a LDAP
LDIF file. An LDIF file is the standard format for representing LDAP
objects. I need to be able to read the records from an LDIF file into
..Net.
There exists a Perl module that will do exactly this called
Net::LDAP::LDIF but I am wanting to port my code over to .Net and
cannot find anything with similar...
|
by: cabrenner |
last post by:
I am new to SQL Server, and migrating part of an Access application to
SSE. I am trying to insert a comma delimited file into SSE 2005. I am
able to run a BULK INSERT statement on a simple file, specifying the
field (,) and row (\n) terminators. I can also do the same with a
format file.
Here is the problem. My csv file has 185 columns, with a mixture of
datatypes. Sometimes, a text field will contain the field delimiter as
part of...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming.
FYI
Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |