Home > Software engineering >  How fast the text according to the line into an array
How fast the text according to the line into an array

Time:09-24

I am using this code
 Open App. Path & amp; "\ test. TXT" For Input As # 1 
Spl ()=Split (StrConv (InputB (LOF (1), 1), vbUnicode), vbCrLf)
Close # 1

But still too slow, I'm a 14 m words this spent has 5 or 6 seconds
Is there any faster? Seconds to save?

CodePudding user response:

This is read, not deposit,

On the premise of file size is the same:
Read just read files faster than first read didn't read the file
Fast reading speed of files on the hard drive is faster than reading speed slow hard disk file
Read no file disk fragments than there are fragments of disk files fast
Read the file does not handle faster than reading while processing
Single thread from the beginning to the end once read documents faster than multi-threaded read file each part respectively (SSD)
Read solid-state hard disk files faster than read common hard disk files

CodePudding user response:

14 m file to be "encoding", more than 50 ten thousand data, feel 5 or 6 seconds already fast enough!
You can be in Form_Load event, to me first. The show window display, in a suitable place to show:
Being loaded data...
After completion of the data load, such as to remove the prompt,

You see the API browser, VB6 load more than 1 m some text, offer two seconds,

CodePudding user response:

With the method of database may be more efficient, the TXT file as a Jet Engine open external database,

CodePudding user response:

ConvertZ code conversion is recommended to use software

CodePudding user response:

reference of123 reply: 3/f
with the method of database may be more efficient, the TXT file as a Jet Engine open external database,

How to operate? Show code,

CodePudding user response:

This involves several technology, the first to open and read the file and have a faster way, the split second, and there is a faster function
Tried before 300 million may also as long as three to five seconds

CodePudding user response:

refer to 6th floor xiaoyao961 response:
it involves several technology, open and read the file first, have a faster way, the split second, and there is a faster function
Tried 300 million may be as long as three to five seconds before

Open, read, by contrast is negligible, it is about 0.2 seconds,
The time spent on the Split and code conversion,

The method of "faster" perhaps, but I'm afraid to verify the actual just know whether feasible,
Pay attention to the building of the file, he more than 14 m file, there are about 50 w to 60 w record data,
You say three to five seconds to complete 300 m file, have you thought about you after the read operation, can with the situation of the building Lord analogy?

CodePudding user response:

refer to 7th floor Chen8013 response:
Quote: refer to the sixth floor xiaoyao961 response:

This involves several technology, the first to open and read the file and have a faster way, the split second, and there is a faster function
Tried 300 million may be as long as three to five seconds before

Open, read, by contrast is negligible, it is about 0.2 seconds,
The time spent on the Split and code conversion,

The method of "faster" perhaps, but I'm afraid to verify the actual just know whether feasible,
Pay attention to the building of the file, he more than 14 m file, there are about 50 w to 60 w record data,
You say three to five seconds to complete 300 m file, have you thought about you after the read operation, can with the situation of the building Lord analogy?

I know, including the SPLIT, all add up to 3-5 seconds, I try again

CodePudding user response:

306 m notepad,
Open the file unavailable=25.9038 microseconds (0.025 ms)
Parsed characters available=3060601.4512 microseconds (3.06 seconds)
Branch takes=1151040.2202 microseconds (1.15 seconds)
Article content line number: 2659302 (255900)

Open the file is a binary format, this the most time consuming step for 3 seconds, I don't know do you have any other API can instead of this, the faster the speed,
Str=StrConv (byte1 (), vbUnicode)

CodePudding user response:

Write the wrong number of rows

306 m notepad,
Open the file unavailable=25.9038 microseconds (0.025 ms)
Parsed characters available=3060601.4512 microseconds (3.06 seconds)
Branch takes=1151040.2202 microseconds (1.15 seconds)
Article content line number: 2659302 (2.66 million)

When open the file is a binary format, "analytical character is" this is the most time consuming step for 3 seconds, I don't know do you have any other API can instead of this, the faster the speed,
Str=StrConv (byte1 (), vbUnicode)

CodePudding user response:

Upstairs, 306 MB file, read less than 26 ms?
You make me play...

At the back of the processing speed so fast that your computer is really tough!

CodePudding user response:

11 references Chen8013 response:
upstairs, 306 MB file, read less than 26 ms?
You make me play...

At the back of the processing speed so fast that your computer is really tough!

Wrong, not 26 ms, but "less than 26 microseconds,"

CodePudding user response:

11 references Chen8013 response:
upstairs, 306 MB file, read less than 26 ms?
You make me play...

At the back of the processing speed so fast that your computer is really tough!


In front of the "25.9038 microseconds (0.025 ms)", is just a transfer of Pointers unavailable, there are some steps before,
Open the file read bytes available complete=693.681 microseconds (including all assigned variables about time together is 0.69 milliseconds to 1 ms)
Allocation of a 306 m alone empty string space with a 0.16 millisecond
Str=String (nFileSize vbNullChar)
There is no relationship and open the file in this step, is used to read in bytes into a string

CodePudding user response:


306 m file,Str=StrConv (byte1 (), vbUnicode)
1.66 secondsDim Str as string
Str=String (nFileSize vbNullChar)
CopyMemory ByVal Str, bytesz (0), nFileSize 3 seconds
Now the question lies in the step 2 time
With CopyMemory also can convert byte to a string, but with longer and for what reason

CodePudding user response:

This is I find on the Internet, time seems quite fast, processing my documents would be less than 2 seconds
 Option Explicit 

Private Declare Function SafeArrayRedim Lib "oleaut32" (ByVal saPtr As Long, saBound As Any) As Long

Public Sub QuickSplit2 (Expression As a String, ResultSplit () As String, Optional Delimiter As String="", Optional ByVal Limit As Long=1)
'general variables that we need
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related