Home > Software engineering >  Excuse me, how to speed up a TXT file generated?
Excuse me, how to speed up a TXT file generated?

Time:11-13

I have a binary file, want to start from a byte, the beginning of the 6 bytes bytes read, read every 6 bytes, after simple treatment, according to certain format into a TXT file, then read the next set of 6 bytes, then write...

I have written the above function, operation and results also have no wrong,

Now my question is, long time running, using the timer, probably need to use 28 seconds, can speed up? The fastest how fast is it?

Content in the binary number in my this is medium, there are several times as much, with my program, not to run for a few minutes? Can't imagine,

Here would like to ask everyone passing by the great god, programs are going to change how to speed up the TXT file generated? Can speed up? The fastest how fast is it?

Here first KouXie everyone a great god,

My program and binary file:
Link: https://pan.baidu.com/s/1JiruySQf903fZ24vetLK3w
The extracted code: 29 tn

CodePudding user response:

One-time write after processing is completed,

CodePudding user response:

A great god, and for writing, seek,

CodePudding user response:

Create a byte array as a buffer, directly modify the array contents, save the direct deposit byte array;

Can also try vb.net, may be a little faster;

CodePudding user response:

Everyone a great god saw my program, should know my program level at entry level, also can only achieve step by step to the file basic literacy level, and all the great spirit of the proposed method, I'm still not sure to understand how to write, than please help me modify my program, can let me reference to craft a real case, study and improve, in addition, a text file or need to generate to statistics, thank you and trouble you a great god,

CodePudding user response:

Your "For q3" that cycle, there is a:
 If abc1 & lt; 0 Then 
Abc1=abc1 + 1
The Else
Abc1=abc1 + 1
End the If

Whatever abc1 values, are all do the same,
You this If statement not reinvent the wheel!

You are the the most fundamental reason, "slow" is in "circulation" operation Text1!!!!!!!!!!
The "Text1. Text" replace with a string variable, estimates that can promote the speed of three times,
Of course, this is just simple correction ", to truly optimization, more than that,
If you wrote, you the processing of the "same", from your "28 seconds" reduced to 2 seconds, should be no big problem,

CodePudding user response:

reference milaoshu1020 reply: 3/f
create a byte array as a buffer, directly modified array contents, save the direct deposit byte array;

Can also try vb.net, may be a little faster;

I think using VB6 application processing, than with the.net application processing is fast,

CodePudding user response:

refer to 6th floor a toast to invite the bright moon response:
I think using VB6 application processing, than with the.net application processing is fast,

I know, vb.net for a large number of string manipulation processing speed faster than VB6;
Vb6 is a=a & amp; B, vb.net has a stringbuffer, can append;

CodePudding user response:

refer to fifth floor a toast to invite the bright moon response:
"For q3" that loop, you have a:
 If abc1 & lt; 0 Then 
Abc1=abc1 + 1
The Else
Abc1=abc1 + 1
End the If

Whatever abc1 values, are all do the same,
You this If statement not reinvent the wheel!

You are the the most fundamental reason, "slow" is in "circulation" operation Text1!!!!!!!!!!
The "Text1. Text" replace with a string variable, estimates that can promote the speed of three times,
Of course, this is just simple correction ", to truly optimization, more than that,
If you wrote, you the processing of the "same", from your "28 seconds" reduced to 2 seconds, should be no big problem,
rightly point out that a large number of operating controls must be slow

CodePudding user response:

Fundamental problem is that you frequently read data bits, and then a small piece of a piece of writing data, a large number of IO waiting to take the time,

Breath in the data is read into memory to (your file is less than 1 million, memory to be able to bear), the processing in memory string concatenation breath again wrote temp files,
You this program should be second level or even millisecond level,

Code doesn't even have a indentation, variable with the serial number changed, too lazy to help you with it yourself
  • Related