mIRC Home    About    Download    Register    News    Help

Print Thread
Hash tables size in bytes #222630 28/06/10 05:16 AM
Joined: Nov 2009
Posts: 81
V
Voglea Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
It possible?

var %i = $hget(0), %s = 0
while (%i) {
var %table = $hget(%i), %t = $hget(%table,0).item, %i = %i - 1
while (%t) var %s = %s + $len($hget(%table,%i).item), %s = %s + $len($hget(%table,%i).data), %t = %t - 1
}
return $bytes(%s).suf

but this is stupid, i think.

Just wanna know, how mIRC using memory, not himself, only bases: hash tables.

Re: Hash tables size in bytes [Re: Voglea] #222631 28/06/10 05:45 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I need to know what kind of data is in your table. Can you show me an item in your table please.

Re: Hash tables size in bytes [Re: Voglea] #222632 28/06/10 06:43 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
It looks like you're trying to determine the amount of memory used by your hash tables.

If so, then the code you wrote is along the right idea. You just have some problems with syntax and structure.

Here's the one I wrote, and tested, and it appears to be correct based upon the data in my hash tables
Code:
alias hash_size {
  var %a = $hget(0)
  while %a {
    var %c = $hget(%a), %d = $hget(%c,0).item
    while %d  {
      var %e = $hget(%c,%d).item, %f = $hget(%c,%d).data
      inc %g $calc($len(%e) + $len(%f))
      dec %d
    }
    dec %a
  }
  echo -a $bytes(%g).suf
}


Re: Hash tables size in bytes [Re: RusselB] #222633 28/06/10 10:10 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Quote:
If so, then the code you wrote is along the right idea. You just have some problems with syntax and structure.
His code is perfectly fine, where are the syntax or structure problem ?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Hash tables size in bytes [Re: Wims] #222648 28/06/10 05:48 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Probably where he tries to calc the numbers without $calc and just uses +.

Re: Hash tables size in bytes [Re: DJ_Sol] #222652 28/06/10 08:09 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You don't need $calc() with /vars ... at least with a basic calculation as was used.

The error is in:
Code:
while (%t) var %s = %s + $len($hget(%table,%i).item), %s = %s + $len($hget(%table,%i).data), %t = %t - 1



%t needs to be used instead of %i in both $hget() sections. That's the only change necessary, but RusselB's is a bit easier to read. smile


Invision Support
#Invision on irc.irchighway.net