mIRC Home    About    Download    Register    News    Help

Print Thread
#227110 26/10/10 12:39 AM
Joined: Oct 2010
Posts: 2
Y
Yoorah Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
Y
Joined: Oct 2010
Posts: 2
Hello,

I wrote a script which searches a text file for a string and outputs the line numbers of any matches. Basically, it counts the number of lines in the text file and then loops through each line, checking it with the isin function.

It worked great in mIRC 6. Since upgrading to 7, however, the search causes mIRC to hang up for 15+ seconds, at 100% CPU usage. This is done while searching a file of about 1500 lines. I realize that it's a big file, but it was still almost instant on mIRC 6. I've tested it in 7.14 and the previous version as well.

Is this a known, unavoidable byproduct of going Unicode, or is this a performance issue that could be fixed?

Thanks!

Last edited by Yoorah; 26/10/10 12:45 AM.
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
The best solution would be to use a different method of searching. For one, $read() has an option to search for text built right into it. Second, you can use /filter to get what you need. And third, /fseek (after doing /fopen and before doing /fclose) can also be useful.

Any of those 3 options would be considerably faster than looping through all of the lines in a file.

Joined: Oct 2010
Posts: 2
Y
Yoorah Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
Y
Joined: Oct 2010
Posts: 2
I appreciate the advice on how to better implement a search, I'll have to try to figure out how to use those instead...

That's not what I made the thread for, however. frown The code worked great in 6, but is performing horribly in 7. I was wondering why, and if it's something that could be fixed.

Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
The switch to Unicode could certainly explain some slowdown, however you haven't really defined what "working great" on 6.x is. so there's no way to say with any confidence if this wholly explains the performance difference you're seeing.

How fast was it running on mIRC 6.x? 50 milliseconds? 1 second? 2 seconds?

It would be great if you could give some actual $ticks-based timing measurements for both 6.x and 7.x so we had some hard numbers to compare.

Joined: Jun 2007
Posts: 930
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 930
File handling as a whole is much much slower, in my experience.
For instance, a logsearch script using /filter on a large log file (50k lines, I believe) took an average of around 10 seconds on v7.x instead of 2-3 seconds on v6.35.
When log files were saved as UTF16 instead of ANSI or UTF8 then this time was cut in half.
I don't have my benchmarks at hand here, but this was the gist.

Joined: Jun 2007
Posts: 930
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 930
As for more specific numbers, this was what I said to someone at the time:
Quote:
When testing /filter on a a log file with ~137k lines, the average time to finish was 8.8 seconds on v7.1 versus 1.9 seconds on v6.35.
Saving the .log file as UTF16 (instead of the default ANSI/UTF8) shortened this to 5.4 seconds (while doubling the file size).


Link Copied to Clipboard