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