Skip to content
General IRCX

making this faster??

A TG007 community discussion started by Rhys.

Discussion 17 posts
Page 1 of 1
Open
Topic #5809 · 17 published posts · 4,295 views

is there a way to make this alias faster? it's getting on my nerves now, when i open my mp3 player, it takes like a minute because mirc freezes.

 

alias loadsongs {
 var %i = 1
 while (%i <= $lines(mp3s.txt)) {
   did -a mp3 1 $replace($duration($calc($mp3($read(mp3s.txt,%i)).length / 1000)),mins,m,secs,s,min,m,sec,s) $chr(9) $remove($nopath($read(mp3s.txt,%i)),.mp3)
   inc %i
 }
}

 

thanks

apparently the best way to do it is use a huge amount of hash tables on startup and load the actual list into a db file but i dont know the technicalities of it, sorry

People are like slinkies; they're generally boring until you push them down stairs

alias loadsongs {
 var %l = 1 , %i
 window -h @mp3
 if ($exists(mp3s.txt)) loadbuf $lines(mp3s.txt) @mp3 mp3s.txt
 while ($line(@mp3,%l)) {
   %i = $ifmatch
   did -a mp3 1 $replace($duration($calc($mp3(%i).length / 1000)),mins,m,secs,s,min,m,sec,s) $chr(9) $remove($nopath(%i),.mp3)
   inc %l
 }
 window -c @mp3
}

 

You could try this.

Edited Jan 7, 2006 2:19 AM by The Gate Keeper

that doesen't put the songs into my dialog.

i had a bracket mismatch, try it again.

I'd actually go for the /filter method:

 

alias loadsongs {
 if ($isfile(mp3s.txt)) filter -fk mp3s.txt addtodialog
}
alias addtodialog did -a mp3 1 $replace($duration($calc($mp3($1-).length /1000)),mins,m,secs,s,min,m,sec,s) $chr(9) $gettok($nopath(%i),-1,46)

Edited Jan 7, 2006 4:19 AM by tidy trax

the master is back.

apparently the best way to do it is use a huge amount of hash tables on startup and load the actual list into a db file but i dont know the technicalities of it, sorry

 

Ugh I've got no idea where you read that but that is definitely not the best way to do it.

arr, if used correctly it can be a lot faster than doing it from a text file.

arr, if used correctly it can be a lot faster than doing it from a text file.

 

Using one or a few hashtables will be quicker than a file, using a huge amount, however, will not.

tgk yours works, but it still takes about a minute. tidy trax yours loads the time, but not the title and it's a little bit quicker.

if it takes such a long time for him to load a simple text files then it wouldnt be a small amount; hash tables have a size limit. huge probably wasnt the best word to use

People are like slinkies; they're generally boring until you push them down stairs

well it's an mp3 player, so it will have quite alot of songs in if i got lots. i'm using about 1200 songs in their, which is 1200 lines in the text file which need to be loaded.

if it takes such a long time for him to load a simple text files then it wouldnt be a small amount; hash tables have a size limit. huge probably wasnt the best word to use

 

Yes they do. That limit is the amount of RAM you have left. You could write millions of entries to a single table without any problems except a huge speed drop as the table gets bigger.

 

The size that you give to a hashtable when you create it using /hmake is not a size limit, but it is the size at which the table is created. Once you fill up the table it is expanded. This is why adding 10,000 items to a table with 100 as the size wouldn't be very efficient (because instead of just adding data, the table needs to be enlarged and the data is then added).

 

tgk yours works, but it still takes about a minute. tidy trax yours loads the time, but not the title and it's a little bit quicker.

 

Sorry about that I forgot to change %i to $1-:

 

alias loadsongs {
if ($isfile(mp3s.txt)) filter -fk mp3s.txt addtodialog
}
alias addtodialog did -a mp3 1 $replace($duration($calc($mp3($1-).length /1000)),mins,m,secs,s,min,m,sec,s) $chr(9) $gettok($nopath($1-),-1,46)

Edited Jan 7, 2006 9:42 PM by hixxy

nope in the title column it just says "mp3" i don't think it can be made any faster

nope in the title column it just says "mp3" i don't think it can be made any faster

 

Another stupid mistake (making a lot of them lately :\). $gettok should be $deltok:

 

alias loadsongs {
if ($isfile(mp3s.txt)) filter -fk mp3s.txt addtodialog
}
alias addtodialog did -a mp3 1 $replace($duration($calc($mp3($1-).length /1000)),mins,m,secs,s,min,m,sec,s) $chr(9) $deltok($nopath($1-),-1,46)

still takes forever.. i don't think you can make it any faster.