mIRC Home    About    Download    Register    News    Help

Print Thread
#273232 24/02/25 06:55 AM
Joined: Feb 2025
Posts: 3
T
Testie Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
T
Joined: Feb 2025
Posts: 3
Please make it work...


[Test Hash Size] Starting test...
[Test Hash Size] Attempting to create hash table of size
[Test Hash Size] Error: Invalid hash table size: 100 ; Explicitly initialize
[Test Hash Size] Test complete. Maximum successful size: -


--------------------------------------------------------------------


; Script to test maximum hash table size in mIRC

alias test_hash_size {
if ($1 == on) {
var %size = 100 ; Explicitly initialize %size
var %increment = 100 ; Increment for each test
var %max_size = 10001 ; Maximum size to test (adjust as needed)
var %used_names = "" ; Variable to store used random names
var %count = 0 ; Counter for bucket ranges

echo -a [Test Hash Size] Starting test...

while (%size <= %max_size) {
; Generate a unique random hash table name
var %random_name
var %name_found = 0 ; Flag to indicate if a unique name is found

while (%name_found == 0) {
%random_name = testhashtable $+ $r(1000, 9999)
if (!$istok(%used_names, %random_name, 32)) {
%name_found = 1 ; Unique name found
}
}

%used_names = %used_names $+ %random_name $+ $chr(32) ; Add name to used names

; Ensure the hash table is deleted before each attempt
if ($hget(%random_name, 1).item != $null) {
hdel %random_name
; Wait until hash table is completely deleted
while ($hget(%random_name, 1).item != $null) {
.delay 10
}
}

echo -a [Test Hash Size] Attempting to create hash table of size %size...
; Check if %random_name is valid before using hmake
if (%random_name != "") {
; Sanitize %size to remove any non-numeric characters
var %sanitized_size = $strip(%size)
; Check if %sanitized_size is valid before using hmake
if ($isnum(%sanitized_size)) {
hmake -s %random_name %sanitized_size
} else {
echo -a [Test Hash Size] Error: Invalid hash table size: %sanitized_size
break
}
} else {
echo -a [Test Hash Size] Error: Invalid hash table name.
break
}

if ($hget(%random_name, 1).item == $null) {
echo -a [Test Hash Size] Hash table of size %sanitized_size created successfully. Size: %sanitized_size
inc %size %increment
inc %count
if (%count >= 100) {
%count = 0
if (%size == 10000) {
%size = 101;
%increment = 1;
} else {
%size = %size + 101;
%increment = 1;
}
}
}
else {
echo -a [Test Hash Size] Failed to create hash table of size %size.
break ; Stop the test
}

; Optionally add a short delay to monitor memory usage
; .delay 1000
}

echo -a [Test Hash Size] Test complete. Maximum successful size: %calc(%size - %increment)
}
else if ($1 == off) {
; Attempt to delete all hash tables starting with "testhashtable"
var %i = 1
while ($hget(testhashtable*, %i).item) {
hdel $hget(testhashtable*, %i).item
inc %i
}
echo -a [Test Hash Size] Test Hash Tables deleted.
}
else {
echo -a [Test Hash Size] Usage: /test_hash_size on|off
}
}

; To run the test, type /test_hash_size on
; To delete the hash tables, type /test_hash_size off

Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
Here is a shorter script, but note that this maximum value has always been known, the maximum value used to be 10001, it's 10007 since mIRC version 7.53 because the number was made to be a prime number.

Code
alias test_hash_size {
  var %s 1
  echo -ag [Test Hash Size] Starting test...
  hfree -w testhashtable*
  while (testhashtable $+ $ticksqpc) {
    hmake $v1 %s
    hfree $v1
    inc %s
  }
  :error
  if ($error) && (hmake isin $v1) {
    reseterror
    dec %s
    echo -ag [Test Hash Size] Test complete. Maximum successful size (number of buckets): %s
    hfree -w testhashtable*
    return
  }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2025
Posts: 3
T
Testie Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
T
Joined: Feb 2025
Posts: 3
Thanks for this.

I knew it was getting too complicated.


Link Copied to Clipboard